Difference between revisions of "Module:Item"
Jump to navigation
Jump to search
m |
m |
||
Line 13: | Line 13: | ||
for key, item in pairs(loaded_data_modules[module_name]) do | for key, item in pairs(loaded_data_modules[module_name]) do | ||
+ | print(item["name"]) | ||
if name == item["name"] then | if name == item["name"] then | ||
return item["id"] | return item["id"] |
Revision as of 09:57, 11 September 2023
local p = {} local data_module_names = { itemData = 'Module:Items/data' } local loaded_data_modules = {} function p.loadItem (name, data_type) local module_name = data_module_names[data_type] if loaded_data_modules[module_name] == nil then loaded_data_modules[module_name] = mw.loadData(module_name) end for key, item in pairs(loaded_data_modules[module_name]) do print(item["name"]) if name == item["name"] then return item["id"] end end return loaded_data_modules[module_name][item] end function p.addSeparator(num) return tostring(num):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse() end function p.item(frame) local args = frame:getParent().args return p._item(args) end function p._item(args) local name = args[1] local id = 0 id = p.loadItem (name, 'itemData') return id end return p