Editing Module:Infobox Item
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 3: | Line 3: | ||
local data_module_names = { | local data_module_names = { | ||
item = 'Module:Items/data', | item = 'Module:Items/data', | ||
− | enchantment = 'Module:Enchantment | + | enchantment = 'Module:Enchantment/data' |
− | |||
} | } | ||
local loaded_data_modules = {} | local loaded_data_modules = {} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function p.loadData(data_type) | function p.loadData(data_type) | ||
Line 65: | Line 18: | ||
local function findItem(name) | local function findItem(name) | ||
− | |||
− | |||
− | |||
− | |||
for key, item in pairs(p.loadData("item")) do | for key, item in pairs(p.loadData("item")) do | ||
− | if | + | if name == item['name'] then |
return item | return item | ||
end | end | ||
end | end | ||
return 0 | return 0 | ||
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 125: | Line 70: | ||
end | end | ||
− | local function | + | local function link(name) |
− | local | + | local s = "" |
− | + | s = "<a href=/p/\"" .. name .. "\" title=\"" .. name .. "\">" .. name .. "</a>" | |
− | + | return s | |
− | |||
− | |||
− | |||
− | |||
− | return | ||
end | end | ||
Line 148: | Line 88: | ||
local function addSeparator(num) | local function addSeparator(num) | ||
return tostring(tonumber(num)):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse() | return tostring(tonumber(num)):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse() | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 247: | Line 95: | ||
local s = "" | local s = "" | ||
args['autoheaders'] = "y" | args['autoheaders'] = "y" | ||
− | |||
− | |||
args['title'] = item['name'] | args['title'] = item['name'] | ||
Line 259: | Line 105: | ||
if item['value'] then | if item['value'] then | ||
− | args[ | + | args['label1'] = icon('Gold', "/images/gold_coin.png") |
− | args[ | + | args['data1'] = addSeparator(item['value']) |
end | end | ||
− | + | local market = require("Module:Market")["_price"]({item['name'], 1, 1}) | |
− | + | if market then | |
− | + | args['label2'] = icon('Market', "/images/ui/marketplace_icon.png") | |
− | + | args['data2'] = addSeparator(market) | |
− | |||
− | |||
− | |||
− | |||
end | end | ||
Line 279: | Line 121: | ||
end | end | ||
s = s:sub(1,s:len()-4) | s = s:sub(1,s:len()-4) | ||
− | args[ | + | args['label3'] = "Level Required" |
− | args[ | + | args['data3'] = s |
+ | end | ||
+ | |||
+ | if item['craftable'] then | ||
+ | args['label4'] = "Source" | ||
+ | args['data4'] = "[[Crafting]]" | ||
end | end | ||
− | |||
− | |||
if item['heat'] then | if item['heat'] then | ||
− | args[ | + | args['label5'] = itemImage(2) |
− | args[ | + | args['data5'] = addSeparator(item['heat']) |
end | end | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
if item['augmentationCost'] then | if item['augmentationCost'] then | ||
s = "" | s = "" | ||
Line 464: | Line 143: | ||
end | end | ||
s = s:sub(1,s:len()-4) | s = s:sub(1,s:len()-4) | ||
− | args[ | + | args['label7'] = "Aug Bonus" |
− | args[ | + | args['data7'] = s |
s = "" | s = "" | ||
Line 473: | Line 152: | ||
end | end | ||
s = s:sub(1,s:len()-4) | s = s:sub(1,s:len()-4) | ||
− | args[ | + | args['label9'] = "Aug Cost" |
− | args[ | + | args['data9'] = s |
+ | end | ||
+ | |||
+ | if item['equipmentStats'] then | ||
+ | if item['equipmentStats']['toolBoost'] then | ||
+ | local s2 = "" | ||
+ | s = "" | ||
+ | for key, stat in pairs(item['equipmentStats']['toolBoost']) do | ||
+ | s = s .. "+" .. stat.skill .. "<br>" | ||
+ | s2 = s2 .. "+" .. stat.boost .. "<br>" | ||
+ | end | ||
+ | s = s:sub(1,s:len()-4) | ||
+ | s2 = s2:sub(1,s2:len()-4) | ||
+ | args['label71'] = s | ||
+ | args['data71'] = s2 | ||
+ | end | ||
end | end | ||
− | args[ | + | args['header20'] = "Cooking" |
if item['size'] then | if item['size'] then | ||
− | args[ | + | args['label21'] = "Size" |
− | args[ | + | args['data21'] = item['size'] |
end | end | ||
if item['difficulty'] then | if item['difficulty'] then | ||
− | args[ | + | args['label22'] = "Difficulty" |
− | args[ | + | args['data22'] = item['difficulty'] |
end | end | ||
Line 495: | Line 189: | ||
end | end | ||
s = s:sub(1,s:len()-4) | s = s:sub(1,s:len()-4) | ||
− | args[ | + | args['label23'] = "Category" |
− | args[ | + | args['data23'] = item['size'] |
end | end | ||
if item['cookingEnchantment'] then | if item['cookingEnchantment'] then | ||
− | args[ | + | args['label24'] = "Buff" |
− | args[ | + | args['data24'] = getEnchantmentName(item['cookingEnchantment']) |
end | end | ||
− | args[ | + | args['header80'] = "Seeds" |
local farming = item['farmingStats'] | local farming = item['farmingStats'] | ||
Line 511: | Line 205: | ||
for key, yield in pairs(farming['yield']) do | for key, yield in pairs(farming['yield']) do | ||
s = s .. yield['min'] .. "-" .. yield['max'] .. " " | s = s .. yield['min'] .. "-" .. yield['max'] .. " " | ||
− | s = s .. | + | s = s .. getItemName(yield['id']) |
if yield['chance'] ~= 1 then | if yield['chance'] ~= 1 then | ||
s = s .. " " .. tonumber(string.format('%.2f', yield['chance'] * 100)) .. "%" | s = s .. " " .. tonumber(string.format('%.2f', yield['chance'] * 100)) .. "%" | ||
Line 518: | Line 212: | ||
end | end | ||
s = s:sub(1,s:len()-4) | s = s:sub(1,s:len()-4) | ||
− | args[ | + | args['label81'] = "Level Required" |
− | args[ | + | args['data81'] = farming['requiredLevel'] |
− | args[ | + | args['label82'] = "Experience" |
− | args[ | + | args['data82'] = farming['experience'] |
− | args[ | + | args['label83'] = "Plot Size" |
− | args[ | + | args['data83'] = farming['height'] .. "x" .. farming['width'] |
− | args[ | + | args['label84'] = "Harvest Time" |
− | args[ | + | args['data84'] = farming['time'] .. " minutes" |
− | args[ | + | args['label85'] = "Yield" |
− | args[ | + | args['data85'] = s |
end | end | ||
Line 535: | Line 229: | ||
args2['bodystyle'] = "padding: 0.5em; margin:auto; font-style:italic; font-size:110%; text-align: center" | args2['bodystyle'] = "padding: 0.5em; margin:auto; font-style:italic; font-size:110%; text-align: center" | ||
args2['data1'] = item['extraTooltipInfo'] | args2['data1'] = item['extraTooltipInfo'] | ||
− | args[ | + | args['header100'] = "Tooltip" |
− | args[ | + | args['data101'] = require('Module:Infobox')['infobox'](args2) |
− | + | args['subbox'] = "no" | |
− | + | args['bodystyle'] = " " | |
− | |||
− | |||
− | |||
− | |||
return require('Module:Infobox')['infobox'](args) | return require('Module:Infobox')['infobox'](args) | ||
Line 553: | Line 243: | ||
function p._item(args) | function p._item(args) | ||
− | local name = | + | local name = args[1] |
local item = 0 | local item = 0 | ||
local infobox = "" | local infobox = "" | ||
− | + | item = findItem (name) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | item = findItem(name) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
infobox = createInfobox(item) | infobox = createInfobox(item) | ||
return infobox | return infobox |