Module:ItemTables: Difference between revisions

Jump to navigation Jump to search
Created page with "local p = {}; local data = mw.loadJsonData("Data:ItemData.json") -- returns the table of a specific item function get_json_item(name) for i,v in pairs(data) do if (v["Name"] == name) then return v end end return nil end --{{#invoke:Sandbox/Sylphoid|get_prop|ITEM_NAME|PROPERTY}}-- --check Data:ItemData.json for properties p.get_prop = function(frame) local item_name = frame.args[1] local property = frame.args[2] local item = get_json_item(item_name) if(ite..."
 
make a table for it
Line 15: Line 15:
--check Data:ItemData.json for properties
--check Data:ItemData.json for properties
p.get_prop = function(frame)
p.get_prop = function(frame)
local shopTableValues = {}
local item_name = frame.args[1]
local item_name = frame.args[1]
local property = frame.args[2]
local property = frame.args[2]
Line 20: Line 21:
if(item == nil) then return "Item Not Found" end
if(item == nil) then return "Item Not Found" end
if(type(item) == table) then
if(type(item) == table) then
local tableValues = get_json_item(item)
for i,v in pairs(item) do
local tableValues = table.insert(shopTableValues, v)
--local tableValues = get_json_item(item)
end
end
end
return tableValues[property]
return tableValues[property]