Module:GSEvent

From [N8]
Revision as of 16:09, 9 August 2021 by Banri (talk | contribs)
Jump to navigation Jump to search
Module documentation
This documentation is transcluded from Module:GSEvent/doc. [edit] [purge]
Module:GSEvent's function main is invoked by Template:/Event.
Module:GSEvent requires Module:Paramtest.
Module:GSEvent is invoked by GSWiki:Events Team/Event.

Generates a table row and outputs event json to smw


-- <nowiki>

local p = {}
local defaults = require('Module:Paramtest').defaults
local lang = mw.language.getContentLanguage()


function p.main( frame )
	local args = frame:getParent().args
	local name, edate, etime, dc, lc, icon, details = defaults{
		{args.name, 'Unnamed'},
		{args.date, 'January 1 1970'},
		{args.time, '00:00'},
		{args.dc, 'GSW'},
		{args.lc, 'Gem'},
		{args.icon, 'G.png'},
		{args.details, 'No Details'}
	}
	local length = tonumber(args.length) or 60
	local world = tonumber(args.world) or 39
	
	local datetime = edate..' '..etime..' UTC'
	local namedisp = '[[File:'..icon..'|link=GSWiki:Events Team/'..name..']]  [[GSWiki:Events Team/'..name..'|'..name..']]'
	
	local ret = mw.html.create( 'tr' )
		:tag('td')	:wikitext( namedisp )								:done()
		:tag('td')	:wikitext( lang:formatDate('F j, G:i' , datetime) )	:done()
		:tag('td')	:wikitext( dc )										:done()
		:tag('td')	:wikitext( 'lc '..lc )					        	:done()
		:tag('td')	:wikitext( details )								:done()
		
	local isotime = lang:formatDate('c', datetime)
	local smwjson = '{"name":"'..name..'","time":"'..lang:formatDate('c', datetime)..'","length":'..length..',"dc":"'..dc..'","lc":'..lc..'}'
	mw.smw.set({ ['Events JSON']=smwjson })
	
	return ret
end

return p

-- </nowiki>