Module:Globals

From Old School Near-Reality Wiki
Revision as of 12:42, 4 October 2022 by Jacmob (talk | contribs) (Created page with "-- <nowiki> -- Implements Template:Globals local p = {} local globals = require 'Module:Globals/data' local opairs = require('Module:Utils').opairs function p.main(frame) local args = frame:getParent().args local global = args[1] -- The arg that was passed local val = globals[global][2] -- The value associated with the arg if (val == nil) then val = '' end return val end function p.doc_list() local ret_table = '' for k,v in opairs(globals) do r...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Module documentation
This documentation is transcluded from Module:Globals/doc. [edit] [history] [purge]
Module:Globals requires Module:Globals/data.
Module:Globals requires Module:Utils.

Access to several global variables like total number of quest points. See Module:Globals/data for the data module.


-- <nowiki>
-- Implements [[Template:Globals]]
 
local p = {}

local globals = require 'Module:Globals/data'
local opairs = require('Module:Utils').opairs
 
function p.main(frame)
	local args = frame:getParent().args
	local global = args[1] -- The arg that was passed
	local val = globals[global][2] -- The value associated with the arg
	
	if (val == nil) then
		val = ''
	end

	return val
end

function p.doc_list()
	local ret_table = ''
	
	for k,v in opairs(globals) do
		ret_table = ret_table..'*\'\'' .. k .. '\'\' &mdash; returns ' .. v[1] .. '\n'
	end
	
	ret_table = ret_table:sub(1, -2)
	
	return ret_table
end
 
return p