Module:MissionDetails: Difference between revisions

Created page with "-- <pre> -- {{Mission details}} -- local p = {} local yesno = require( 'Module:Yesno' ) local onmain = require('Module:Mainonly').on_main() local difficulties = { no..."
 
mNo edit summary
 
(17 intermediate revisions by the same user not shown)
Line 8: Line 8:
      
      
local difficulties = {
local difficulties = {
     none = 'None',
     veryeasy = 'Very Easy',
     tutorial = '[[File:Novice.svg|7px|Tutorial|link=]] Tutorial',
     easy = 'Easy',
     novice = '[[File:Novice.svg|7px|Novice|link=]] Novice',
     standard = 'Standard',
     intermediate = '[[File:Intermediate.svg|7px|Intermediate|link=]] Intermediate',
     moderate = 'Moderate',
     experienced = '[[File:Experienced.svg|7px|Experienced|link=]] Experienced',
     hard = 'Hard',
     master = '[[File:Master.svg|7px|Master|link=]] Master',
     veryhard = 'Very Hard',
     grandmaster = '[[File:Grandmaster.svg|7px|Grandmaster|link=]] Grandmaster',
     impossible = 'Impossible',
    special = '[[File:Special.svg|7px|Special|link=]] Special'
}
}
   
function p.details( frame )
function p.details( frame )
     local _args = frame:getParent().args
     local _args = frame:getParent().args
Line 36: Line 34:
     local icon = args.icon and '[[File:' .. args.icon .. '|50px|right]]' or ''
     local icon = args.icon and '[[File:' .. args.icon .. '|50px|right]]' or ''
     local start = args.start or unknown
     local start = args.start or unknown
    local members = yesno( args.members ) and '[[File:P2P icon.png|30px|link=]] Members only' or
        -- check it's actually set to something false-y
        yesno( args.members ) == false and '[[File:F2P icon.png|30px|link=]] Free to play' or unknown
     local difficulty = difficulties[mw.ustring.lower(args.difficulty or '')] or unknown
     local difficulty = difficulties[mw.ustring.lower(args.difficulty or '')] or unknown
     local length = args.length or unknown
     local length = args.length or unknown
Line 57: Line 52:
             :tag( 'td' )
             :tag( 'td' )
                 :addClass( 'missiondetails-info' )
                 :addClass( 'missiondetails-info' )
                 :wikitext( '[[File:mission map icon.png|17px|link=]] ' .. icon .. start )
                 :wikitext( '' .. icon .. start )
                :done()
            :done()
        :tag( 'tr' )
            :tag( 'th' )
                :addClass( 'missiondetails-header' )
                :wikitext( 'Member requirement' )
                :done()
            :tag( 'td' )
                :addClass( 'missiondetails-info' )
                :wikitext( members )
                 :done()
                 :done()
             :done()
             :done()
Line 99: Line 84:
                 :addClass( 'qc-active' )
                 :addClass( 'qc-active' )
                 :tag( 'i' )
                 :tag( 'i' )
                     :wikitext( 'Skill requirements are not boostable unless marked with a [B] for boostable.' )
                     :wikitext( '' )
                     :done()
                     :done()
                 :newline():newline()
                 :newline():newline()
Line 113: Line 98:
                 :addClass( 'missiondetails-info' )
                 :addClass( 'missiondetails-info' )
                 :tag( 'i' )
                 :tag( 'i' )
                     :wikitext( 'Items from the [[tool belt]] are not listed unless they do not work or are not automatically added.' )
                     :wikitext( '' )
                     :done()
                     :done()
                 :newline():newline()
                 :newline():newline()
Line 169: Line 154:
items = args.items or 'None',
items = args.items or 'None',
kills = args.kills or 'None',
kills = args.kills or 'None',
members = yesno(args.members,false)
}
}
local jsongood, encsmwJSON = pcall(mw.text.jsonEncode, smwJSON)
local jsongood, encsmwJSON = pcall(mw.text.jsonEncode, smwJSON)
Line 192: Line 176:
local smw = {
local smw = {
['Official difficulty'] = args.difficulty or nil,
['Official difficulty'] = args.difficulty or nil,
['Is members only'] = yesno(args.members,false),
['Official length'] = args.length or nil,
['Official length'] = args.length or nil,
}
}
local smwstat = mw.smw.set(smw)
if not smwstat == true then
err = err .. ' ' .. smwstat.error
end
return tostring(info) .. tostring(err)
return tostring(info) .. tostring(err)