Module:ItemData: Difference between revisions

add color to error, return values of subtable in properties
m cleanup
Line 16: Line 16:
local item_name = frame.args[1]
local item_name = frame.args[1]
local item = get_json_item(item_name)
local item = get_json_item(item_name)
if(item == nil) then return "<span style=\"color:red;\">\"Item Not Found.</span>" end
if(item == nil) then return "<span style=\"color:red;\">Item Not Found.</span>" end
local cost = 0
local cost = 0
Line 35: Line 35:
local item_name = frame.args[1]
local item_name = frame.args[1]
local item = get_json_item(item_name)
local item = get_json_item(item_name)
if(item == nil) then return "<span style=\"color:red;\">\"Item Not Found.</span>" end
if(item == nil) then return "<span style=\"color:red;\">Item Not Found.</span>" end
if (item["Slot"] == "Weapon") then
if (item["Slot"] == "Weapon") then
Line 52: Line 52:
local item_name = frame.args[1]
local item_name = frame.args[1]
local item = get_json_item(item_name)
local item = get_json_item(item_name)
if(item == nil) then return "<span style=\"color:red;\">\"Item Not Found.</span>" end
if(item == nil) then return "<span style=\"color:red;\">Item Not Found.</span>" end
if (item["Activation"] == "Passive") then
if (item["Activation"] == "Passive") then
Line 68: Line 68:
local property = frame.args[2]
local property = frame.args[2]
local item = get_json_item(item_name)
local item = get_json_item(item_name)
if(item == nil) then return "<span style=\"color:red;\">\"Item Not Found.</span>" end
if(item == nil) then return "<span style=\"color:red;\">Item Not Found.</span>" end
if(type(item[property]) == "table") then
if(type(item[property]) == "table") then
for i,v in pairs(item[property]) do
for i,v in pairs(item[property]) do
Line 82: Line 82:
local item_name = frame.args[1]
local item_name = frame.args[1]
local item = get_json_item(item_name)
local item = get_json_item(item_name)
if(item == nil) then return "<span style=\"color:red;\">\"Item Not Found.</span>" end
if(item == nil) then return "<span style=\"color:red;\">Item Not Found.</span>" end
local components = item['Components']
local components = item['Components']