Module:Location Table: Difference between revisions
Repurpose so this can work with the seperate LocTableHead/LocLine/LocTableBottom templates
m (Artoire moved page Module:Sandbox/User:Artoire/Location Table to Module:Location Table without leaving a redirect: Move out of sandbox) |
(Repurpose so this can work with the seperate LocTableHead/LocLine/LocTableBottom templates) |
||
Line 1:
require('strict')
local persistant = require('Module:Break Isolation').get_module_store('Module:Location Table')
local parse = require('Module:Param Parse')
local edit = 'Unknown <span class="small plainlinks">' .. require('Module:Edit button')() .. '</span>'
persistant.counter = persistant.counter or 0
local p = {}
function p.
assert(not persistant.in_table, 'Second {{LocTableHead}} (Missing {{LocTableBottom}}?)')
persistant.in_table = true
persistant.json = {}
end▼
end
function p.
assert(persistant.in_table, '{{LocLine}} when not in a location table (Missing {{LocTableHead}}?)')
local args = frame:getParent().args
persistant.counter = persistant.counter + 1
▲ local loc_version = args.version
local id = 'LOC_' .. persistant.counter
▲ local location_object = mw.title.getCurrentTitle().fullText
▲ if loc_version then
▲ location_object = location_object .. '#' .. loc_version
▲ end
▲ local loc = args['loc'..i]
end▼
▲ local qty = args['qty'..i]
▲ qty = tonumber(qty or '')
▲ loc_json[loc] = qty or -1
▲ local loc_link = ('[[%s]]'):format(loc)
▲ local episode = mw.smw.ask{loc_link, '?Episode#=', 'mainlabel=-'}
▲ episode = episode and episode[1][1]
function p.bottom(frame)
▲ mw.smw.subobject({
assert(persistant.in_table, '{{LocTableBottom}} when not in a location table (Missing {{LocTableHead}}?)')
▲ ['Location object'] = location_object,
▲ ['Located in'] = loc,
▲ ['Location quantity'] = qty or 'Unknown'
▲ }, id)
if
mw.smw.subobject({ ['Location JSON'] = mw.text.jsonEncode(
else
mw.smw.set{ ['Location JSON'] = mw.text.jsonEncode(
end
persistant.in_table = nil
persistant.json = nil
persistant.version = nil
persistant.location_object = nil
end
|