Difference between revisions of "Module:Silent1/sandbox"
Jump to navigation
Jump to search
m (Replaced content with "local p = {} local origArgs = {} local data_module_names = { item = 'Module:Silent1/sandbox/data' } local loaded_data_modules = {} function p.loadData (data_type) loc...") Tag: Replaced |
m |
||
Line 18: | Line 18: | ||
function p.findItemID(name) | function p.findItemID(name) | ||
local items = p.loadData('item') | local items = p.loadData('item') | ||
− | local lname = lower(name) | + | local lname = string.lower(name) |
local id = 0 | local id = 0 | ||
for k,v in pairs(items) do | for k,v in pairs(items) do | ||
− | if lname == lower(v[name]) then | + | if lname == string.lower(v[name]) then |
id = k | id = k | ||
return id | return id |
Revision as of 10:33, 14 February 2022
local p = {} local origArgs = {} local data_module_names = { item = 'Module:Silent1/sandbox/data' } local loaded_data_modules = {} function p.loadData (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 return loaded_data_modules[module_name] end function p.findItemID(name) local items = p.loadData('item') local lname = string.lower(name) local id = 0 for k,v in pairs(items) do if lname == string.lower(v[name]) then id = k return id end end return id end function p.getURL(id) return 'https://idlescape.com' .. p.loadData('item')[id][itemImage] end -- If called via #invoke, use the args passed into the invoking template. -- Otherwise, for testing purposes, assume args are being passed directly in. function p.image(frame) if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args else origArgs = frame end local id = p.findItemID(origArgs[1]) return p.getURL(id) end return p