Module:Infobox Item
Jump to navigation
Jump to search
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 if name == item["name"] then return item end end return 0 end function p.addSeparator(num) return tostring(num):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse() end function p.fullUrl(url) local newUrl = "" if url:sub(1,5) ~= "https" then return url end if url:sub(1,1) ~= "/" then newUrl = "/" .. url end newUrl = "https://www.play.idlescape.com" .. newUrl return newUrl end function p.item(frame) local args = frame:getParent().args return p._item(args) end function p._item(args) local name = args[1] local item = 0 local infobox = "" item = p.loadItem (name, 'itemData') infobox = p.createInfobox(item) return infobox end function p.createInfobox(item) local s = "" local url = "" s = s .. "|title ={{{title|{{PAGENAME}}}}}\n" if item["itemIcon"] then url = item["itemIcon"] else url = item["itemImage"] end s = s .. "|image ={{{image|}}}|<img src=\"" .. p.fullUrl(url) .. "\" height=\"auto\" width=\"150\">|{{img|{{PAGENAME}}|150}}}}\n" return s end return p