Module:Silent1/sandbox
Jump to navigation
Jump to search
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 = tostring(p.findItemID(origArgs[1])) return p.getURL(id) end return p