Difference between revisions of "Module:IPC"

Line 1: Line 1:
my_object = {};    --All lua modules on Wikipedia must begin by defining a variable
+
local capiunto = require 'capiunto'
                    --that will hold their externally accessible functions.
+
capiunto.create( {
                    --Such variables can have whatever name you want and may
+
title = 'Title of the Infobox'
                    --also contain various data as well as functions.
+
} )
 
+
:addRow( 'A label', 'some data' )
my_object.hello = function( frame )    --Add a function to "my_object". 
+
:addHeader( 'A header between the data rows' )
                                        --Such functions are callable in Wikipedia
+
:addRow( 'Another label', 'more data' )
                                        --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"
 
 
 
return my_object    --All modules end by returning the variable containing its
 
                    --functions to Wikipedia.
 
 
 
-- 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 Wikipedia.  All output is accomplished
 
-- via strings "returned" to Wikipedia.
 

Revision as of 21:15, 20 July 2016

Documentation for this module may be created at Module:IPC/doc

Script error: Lua error: Internal error: The interpreter exited with status 127.

local capiunto = require 'capiunto'
capiunto.create( {
	title = 'Title of the Infobox'
} )
:addRow( 'A label', 'some data' )
:addHeader( 'A header between the data rows' )
:addRow( 'Another label', 'more data' )