Module:Sandbox/One Bar: Difference between revisions

From The Deadlock Wiki
Jump to navigation Jump to search
One Bar (talk | contribs)
other function
One Bar (talk | contribs)
typo
Line 15: Line 15:
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
return cur_item["Cost"]
return item["Cost"]
end
end



Revision as of 00:12, 9 May 2025

Documentation for this module may be created at Module:Sandbox/One Bar/doc

local p = {};
local data = mw.loadJsonData("Data:ItemData.json")

local function get_json_item(name)
	for _, v in pairs(data) do
		if (v["Name"] == name) then
			return v
		end
	end
	return nil
end

local function get_cost(item_name)
	local item = get_json_item(item_name)
	if(item == nil) then return "<span style=\"color:red;\">Item Not Found.</span>" end
	
	return item["Cost"]
end

p.get_cost = function(frame)
	local item_name = frame.args[1]
	return Format(get_cost(item_name))
end

-- Module access point
function p._get_cost(a)
	a = tostring(a) or '0'
	return get_cost(a)
end

return p