Editing Module:Location Table

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
require('strict')
require('strict')
local persistant = require('Module:Break Isolation').get_module_store('Module:Location Table')
local parse = require('Module:Param Parse')
local parse = require('Module:Param Parse')
local edit = 'Unknown <span class="small plainlinks">' .. require('Module:Edit button')() .. '</span>'
local edit = 'Unknown <span class="small plainlinks">' .. require('Module:Edit button')() .. '</span>'

persistant.counter = persistant.counter or 0


local p = {}
local p = {}


function p.head(frame)
function p.main(frame)
local args = frame:getParent().args
return p._main(frame:getParent().args)
assert(not persistant.in_table, 'Second Template:LocTableHead (Missing Template:LocTableBottom?)')
persistant.in_table = true
persistant.json = {}
persistant.version = args.version
persistant.location_object = mw.title.getCurrentTitle().fullText
if args.version then
persistant.location_object = persistant.location_object .. '#' .. args.version
end
end
end


function p.line(frame)
function p._main(args)
local tbl = mw.html.create('table')
assert(persistant.in_table, 'Template:LocLine when not in a location table (Missing Template:LocTableHead?)')
:addClass('wikitable sortable filterable sticky-header loctable autosort=1,a')
local args = frame:getParent().args
:css{ ['text-align'] = 'center' }
local loc = args.loc
:tag('tr')
local qty = args.quantity
:tag('th'):wikitext('Location'):done()
qty = tonumber(qty or '')
:tag('th'):wikitext('Episode'):done()
persistant.json[loc] = qty or -1
:tag('th'):wikitext('Qty.'):done()
local loc_link = ('[[%s]]'):format(loc)
:done()
local episode = mw.smw.ask{loc_link, '?Episode#=', 'mainlabel=-'}
episode = episode and episode[1][1]


local loc_version = args.version
persistant.counter = persistant.counter + 1
local location_object = mw.title.getCurrentTitle().fullText
local id = 'LOC_' .. persistant.counter
local id_prefix = 'LOC_'
if loc_version then
location_object = location_object .. '#' .. loc_version
id_prefix = id_prefix .. loc_version .. '_'
end
local loc_json = {}


for i = 1, 9007199254740992 do
mw.smw.subobject({
local loc = args['loc'..i]
['Location object'] = persistant.location_object,
['Located in'] = loc,
if not loc then
break
['Location quantity'] = qty or 'Unknown'
end
}, id)
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]
local id = id_prefix .. loc


return mw.html.create('tr')
tbl:tag('tr')
:attr{ id = id }
:attr{ id = id }
:tag('td'):wikitext(loc_link):done()
:tag('td'):wikitext(loc_link)
:tag('td'):wikitext(parse.episode_func(episode)):done()
:tag('td'):wikitext(parse.episode_func(episode)):done()
:tag('td'):wikitext(qty or edit):done()
:tag('td'):wikitext(qty or edit):done()
:done()
:done()
end


mw.smw.subobject({
function p.bottom(frame)
['Location object'] = location_object,
assert(persistant.in_table, 'Template:LocTableBottom when not in a location table (Missing Template:LocTableHead?)')
['Located in'] = loc,
['Location quantity'] = qty or 'Unknown'
}, id)
end


if persistant.version then
if loc_version then
mw.smw.subobject({ ['Location JSON'] = mw.text.jsonEncode(persistant.json) }, persistant.version)
mw.smw.subobject({ ['Location JSON'] = mw.text.jsonEncode(loc_json) }, loc_version)
else
else
mw.smw.set{ ['Location JSON'] = mw.text.jsonEncode(persistant.json) }
mw.smw.set{ ['Location JSON'] = mw.text.jsonEncode(loc_json) }
end
end


return tbl
persistant.in_table = nil
persistant.json = nil
persistant.version = nil
persistant.location_object = nil
end
end


Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see Brighter Shores:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template

This page is a member of a hidden category: