PC Gaming Shelter
An archive dedicated to preserving PC Gaming history and more

Module:Universe

From PC Gaming Shelter
Revision as of 10:07, 31 July 2026 by WikiVisor (talk | contribs)

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

local utils = require( 'Module:Utils' )

local p = {}

local function getCurrentGame()
	local title = mw.title.getCurrentTitle()
	local game  = title.rootText
	local resource = title.subpageText
	local data = {
		['game'] = game,
		['resource'] = resource,
	}
	return data
end

local function setDisplayTitle(frame, title)
	local displayTitle = frame:preprocess(string.format('{{DISPLAYTITLE:%s|noreplace, noerror}}', title))
	return displayTitle
end

function p.Mods(frame)
	local data     = getCurrentGame()
	local game     = data.game
	local resource = data.resource
	local query = {
		'[[Category:Mods||Maps||Skins||Utilities]][[Related game::' .. game .. ']]'		
	}
	local content = mw.smw.ask(query)
	
	local forminput = frame:callParserFunction({ name = '#forminput', '', args = {
		'form=Mod',
		'query string=Mod[Related game]=' .. game,
		'button text=Create or Edit Mod',
		'autofocus=no'
	}}) 

	setDisplayTitle(frame, string.format('%s %s', game, resource))
	
	return forminput 
end

function p.Players()
	local data     = getCurrentGame()
	local game     = data.game
	local resource = data.resource
	
	local query = {
		'[[Category:Players]][[Plays game::' .. getCurrentGame() .. ']]'		
	}
	
	local content = mw.smw.ask(query)
	
	local forminput = frame:callParserFunction({ name = '#forminput', '', args = {
		'form=Player',
		'query string=Player[Plays game]=' .. game,
		'button text=Create or Edit Player Entry',
		'autocomplete on category=Players',
		'autofocus=no'
	}})

	setDisplayTitle(frame, string.format('%s %s', game, resource))

	return forminput
end

function p.Clans()
	local data     = getCurrentGame()
	local game     = data.game
	local resource = data.resource
	
	local query = {
		'[[Category:Communities]][[Related game::' .. getCurrentGame() .. ']]'		
	}
	
	local content = mw.smw.ask(query)
	
	local forminput = frame:callParserFunction({ name = '#forminput', '', args = {
		'form=Community',
		'query string=Community[Related game]=' .. game,
		'button text=Create or Edit Community Entry',
		'autocomplete on category=Communities',
		'autofocus=no'
	}})

	setDisplayTitle(frame, string.format('%s %s', game, resource))

	return forminput
end

return p