Module:TableGenerator: Difference between revisions
From AoP Wiki
Testing |
Ammo List Module Update |
||
Line 3: | Line 3: | ||
local p = {} | local p = {} | ||
function | local function getAmmoTable() | ||
local records = mw.ext.externalData.getExternalData 'http://localhost/foaop/planner/ammo.json'.__json | local records = mw.ext.externalData.getExternalData 'http://localhost/foaop/planner/ammo.json'.__json | ||
local length = 0 | local length = 0 | ||
Line 15: | Line 15: | ||
if length == 5 then | if length == 5 then | ||
mw.logObject(ammoTable) | --mw.logObject(ammoTable) | ||
return ammoTable | return ammoTable | ||
end | end | ||
end | end | ||
return false | return false | ||
end | |||
function p.getAmmoList(frame) | |||
local ammoList = getAmmoList() | |||
if not ammoList then | |||
return "No ammo data available." | |||
end | |||
local output = "" | |||
for _, ammo in ipairs(ammoList) do | |||
output = output .."{{!}}-".."\n" | |||
output = output .."{{!}}".. ammo.ProtoId .."\n" | |||
output = output .."{{!}}".. ammo.Tier .."\n" | |||
output = output .."{{!}}[[".. ammo.Name .."]]\n" | |||
output = output .."{{!}}https://uralez.de/foaop/planner/".. ammo.PicInv .."\n" | |||
end | |||
return output | |||
end | end | ||
Revision as of 17:44, 24 February 2025
Documentation for this module may be created at Module:TableGenerator/doc
--print(), mw.log() and mw.logObject()
local p = {}
local function getAmmoTable()
local records = mw.ext.externalData.getExternalData 'http://localhost/foaop/planner/ammo.json'.__json
local length = 0
local ammoTable = {}
for k,v in pairs(records) do
if v.Tier then
table.insert(ammoTable, v)
length = length +1
end
if length == 5 then
--mw.logObject(ammoTable)
return ammoTable
end
end
return false
end
function p.getAmmoList(frame)
local ammoList = getAmmoList()
if not ammoList then
return "No ammo data available."
end
local output = ""
for _, ammo in ipairs(ammoList) do
output = output .."{{!}}-".."\n"
output = output .."{{!}}".. ammo.ProtoId .."\n"
output = output .."{{!}}".. ammo.Tier .."\n"
output = output .."{{!}}[[".. ammo.Name .."]]\n"
output = output .."{{!}}https://uralez.de/foaop/planner/".. ammo.PicInv .."\n"
end
return output
end
function p.main(frame)
local args = frame.args
local records = mw.ext.externalData.getExternalData 'http://localhost/foaop/planner/ammo.json'.__json
local id = 29
local record = mw.ext.externalData.getExternalData {
source = 'http://localhost/foaop/planner/ammo.json',
format = 'json with jsonpath',
data = { record = '$[?(@.ProtoId == ' .. tostring (id) .. ')]' }
}.record
mw.logObject(record2)
return args[1]..args["sep"]..args[2]
end
return p