Jump to content

The wiki is in the process of updating to the latest major game changes. Any contributions are appreciated!
Start here to learn how to edit and join our Discord server to make suggestions.

Module:ItemTables

From The Deadlock Wiki
Revision as of 06:23, 20 September 2024 by Sylphoid (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Module used to create item tables with Template:Item stat table.

To add a new stat, add the name of the stat as "friendly to internal", followed by the property as listed on Data:ItemData.json, as well as adding the property to the "local unitSuffix" list corresponding to its suffix.


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(item == nil) then return "Item Not Found" end
	if(type(item) == table) then
		local tableValues = get_json_item(item)
	end
	return tableValues[property]
end

return p