Module:Sandbox/WikiMacaroons/Testlua

Revision as of 11:28, 12 June 2020 by imported>WikiMacaroons (Created page with 'local p = {}; --All lua modules on Wikipedia must begin by defining a variable --that will hold their externally accessible functions....')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/WikiMacaroons/Testlua/doc

local p = {};     --All lua modules on Wikipedia 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 Wikipedia
                                        --via the #invoke command.
                                        --"frame" will contain the data that Wikipedia
                                        --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 Wikipedia.
    
end  -- end of the function "hello"