Difference between revisions of "Module:HelloWorld"

Jump to navigation Jump to search
No change in size ,  14:21, 15 April 2019
m
no edit summary
(Test 2)
 
m
 
Line 1: Line 1:
local p = {};    --All lua modules on Wikipedia must begin by defining a variable  
local p = {};    --All lua modules on Mediawiki 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 Wikipedia
                                         --Such functions are callable in Mediawiki
                                         --via the #invoke command.
                                         --via the #invoke command.
                                         --"frame" will contain the data that Wikipedia
                                         --"frame" will contain the data that Mediawiki
                                         --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 Wikipedia.
                   --"str" back to Mediawiki.
      
      
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 Wikipedia.
                     --functions to Mediawiki.


-- 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 Wikipedia.  All output is accomplished
-- The "print" function is not allowed in Mediawiki.  All output is accomplished
-- via strings "returned" to Wikipedia.
-- via strings "returned" to Mediawiki.

Navigation menu