Module:Universe: Difference between revisions
From PC Gaming Shelter
No edit summary |
No edit summary |
||
| Line 5: | Line 5: | ||
local function getCurrentGame() | local function getCurrentGame() | ||
local title = mw.title.getCurrentTitle() | local title = mw.title.getCurrentTitle() | ||
local game = title. | local game = title.root | ||
return | local resource = title.text | ||
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 | end | ||
function p.Mods(frame) | function p.Mods(frame) | ||
local | local data = getCurrentGame() | ||
local game = data.game | |||
local resource = data.resource | |||
local query = { | local query = { | ||
'[[Category:Mods||Maps||Skins||Utilities]][[Related game::' .. game .. ']]' | '[[Category:Mods||Maps||Skins||Utilities]][[Related game::' .. game .. ']]' | ||
| Line 24: | Line 36: | ||
local html = mw.html.create() | local html = mw.html.create() | ||
setDisplayTitle(frame, string.format('%s %s', game, resource)) | |||
return forminput | return forminput | ||
Revision as of 09:56, 31 July 2026
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.root
local resource = title.text
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 data = 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'
}})
local html = mw.html.create()
setDisplayTitle(frame, string.format('%s %s', game, resource))
return forminput
end
function p.Players()
local query = {
'[[Category:Players]][[Plays game::' .. getCurrentGame() .. ']]'
}
return mw.smw.ask(query)
end
function p.Clans()
local query = {
'[[Category:Communities]][[Related game::' .. getCurrentGame() .. ']]'
}
return mw.smw.ask(query)
end
return p
