Module:HelloWorld: Difference between revisions
(HelloWorld) |
WikiDwarfBOT (talk | contribs) m (→top: clean up, replaced: Wikipedia → Bharatpedia (7)) |
||
Line 1: | Line 1: | ||
local p = {}; --All lua modules on | local p = {}; --All lua modules on Bharatpedia must begin by defining a variable | ||
--that will hold their externally accessible functions. | --that will hold their externally accessible functions. | ||
--Such variables can have whatever name you want and may | --Such variables can have whatever name you want and may | ||
Line 5: | Line 5: | ||
p.hello = function( frame ) --Add a function to "my_object". | p.hello = function( frame ) --Add a function to "my_object". | ||
--Such functions are callable in | --Such functions are callable in Bharatpedia | ||
--via the #invoke command. | --via the #invoke command. | ||
--"frame" will contain the data that | --"frame" will contain the data that Bharatpedia | ||
--sends this function when it runs. | --sends this function when it runs. | ||
Line 14: | Line 14: | ||
return str --This tells us to quit this function and send the information in | return str --This tells us to quit this function and send the information in | ||
--"str" back to | --"str" back to Bharatpedia. | ||
end -- end of the function "hello" | end -- end of the function "hello" | ||
return p --All modules end by returning the variable containing its | return p --All modules end by returning the variable containing its | ||
--functions to | --functions to Bharatpedia. | ||
-- Now we can use this module by calling {{#invoke: HelloWorld | hello }}. | -- Now we can use this module by calling {{#invoke: HelloWorld | hello }}. | ||
Line 26: | Line 26: | ||
-- variable that you returned. | -- variable that you returned. | ||
-- The "print" function is not allowed in | -- The "print" function is not allowed in Bharatpedia. All output is accomplished | ||
-- via strings "returned" to | -- via strings "returned" to Bharatpedia. |
Latest revision as of 19:44, 5 June 2021
Documentation for this module may be created at Module:HelloWorld/doc
local p = {}; --All lua modules on Bharatpedia must begin by defining a variable --that will hold their externally accessible functions. --Such variables can have whatever name you want and may --also contain various data as well as functions. p.hello = function( frame ) --Add a function to "my_object". --Such functions are callable in Bharatpedia --via the #invoke command. --"frame" will contain the data that Bharatpedia --sends this function when it runs. local str = "Hello World!" --Declare a local variable and set it equal to --"Hello World!". return str --This tells us to quit this function and send the information in --"str" back to Bharatpedia. end -- end of the function "hello" return p --All modules end by returning the variable containing its --functions to Bharatpedia. -- Now we can use this module by calling {{#invoke: HelloWorld | hello }}. -- Note that the first part of the invoke is the name of the Module's wikipage, -- and the second part is the name of one of the functions attached to the -- variable that you returned. -- The "print" function is not allowed in Bharatpedia. All output is accomplished -- via strings "returned" to Bharatpedia.