Module:TableGenerator: Difference between revisions

From AoP Wiki
Created Ammo List Module for testing out stuffs
 
Testing
Line 5: Line 5:
function p.getAmmoList()
function p.getAmmoList()
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 table = {}
local length = 0
local ammoTable = {}
for k,v in pairs(records) do
for k,v in pairs(records) do
if v.Tier then
if v.Tier then
mw.logObject(v)
table.insert(ammoTable, v)
--mw.log(k,v)
length = length +1
length = length +1
end
end
if length == 5 then
if length == 5 then
mw.logObject(ammoTable)
return true
return true
end
end

Revision as of 17:19, 24 February 2025

Documentation for this module may be created at Module:TableGenerator/doc

--print(), mw.log() and mw.logObject()

local p = {}

function p.getAmmoList()
	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 true
		end
	end
	

	return true
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