Module:QueryMapSummary: Difference between revisions
Jump to navigation
Jump to search
(Created page with "local p = {} local cargo = mw.ext.cargo function p.main ( frame ) local tables = "MAINMap" local fields = "TXT_MapDescription" local cargoArgs = { where = "MAINMap.TXT_MapName = '" .. frame.args.map .. "'", default ='Description not defined', limit = 1 } local results = cargo.query( tables, fields, cargoArgs ) for r = 1, #results do local result = results[r] if result == nil then return 'Empty Cargo...'...") |
m (Protected "Module:QueryMapSummary": Prevent editing of templates ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))) |
(No difference)
| |
Latest revision as of 17:47, 3 June 2023
Description[edit source]
Retrieve a Map's ingame Description text. Only necessary because of a conflict between ConfirmEdit/QuestyCaptcha and Cargo that resulted in Cargo-stored text containing double quotes turning into the HTML escaped version when retrieved like the below seen with Belles.
To Use[edit source]
This code was written for the MapPage template but if needed elsewhere, copy and paste the following.
{{#invoke:QueryMapSummary|main|map={{#replace:{{PAGENAME}}|'|\'}}}}
If not using the name of the page, swap PAGENAME with the Map's name. The "replace" code is needed to handle names that contain single quotes which would otherwise cause database errors if not properly escaped prior to being queried for.
On MapPage, the text is also italicized.
local p = {}
local cargo = mw.ext.cargo
function p.main ( frame )
local tables = "MAINMap"
local fields = "TXT_MapDescription"
local cargoArgs = {
where = "MAINMap.TXT_MapName = '" .. frame.args.map .. "'",
default ='Description not defined',
limit = 1
}
local results = cargo.query( tables, fields, cargoArgs )
for r = 1, #results do
local result = results[r]
if result == nil then
return 'Empty Cargo...'
else
return result.TXT_MapDescription
end
end
end
return p