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 105: | Line 50: | ||
local function icon(name, url, word) | local function icon(name, url, word) | ||
local s = fullUrl(url) | local s = fullUrl(url) | ||
− | s = " | + | s = "<a href=/p/\"" .. name .. "\" title=\"" .. name .. "\"><img src=\"" .. s |
s = s .. "\" alt=\"" .. name .. "\" width=\"20\">" | s = s .. "\" alt=\"" .. name .. "\" width=\"20\">" | ||
if word then | if word then | ||
s = s .. name | s = s .. name | ||
end | end | ||
− | s = s .. " | + | s = s .. "</a>" |
return s | return s | ||
end | end | ||
− | local function itemImage(id | + | local function itemImage(id) |
local item = p.loadData("item")[tostring(id)] | local item = p.loadData("item")[tostring(id)] | ||
local url = "" | local url = "" | ||
Line 122: | Line 67: | ||
url = item['itemImage'] | url = item['itemImage'] | ||
end | end | ||
− | return icon(item['name'], url | + | return icon(item['name'], url) |
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 256: | Line 102: | ||
url = item['itemImage'] | url = item['itemImage'] | ||
end | end | ||
− | args['image'] = | + | args['image'] = fullUrl(url) |
if item['value'] then | if item['value'] then | ||
− | args[ | + | args['label1'] = itemImage(1) |
− | 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(item['value']) | |
− | |||
− | |||
− | |||
− | |||
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'] = link("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 = "" | ||
for key, cost in pairs(item['augmentationCost']) do | for key, cost in pairs(item['augmentationCost']) do | ||
s = s .. cost .. " " | s = s .. cost .. " " | ||
− | s = s .. | + | s = s .. "{{img|" .. getItemName(key) .."|word=1}}" .. "<br>" |
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 | 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 174: | ||
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 190: | ||
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 197: | ||
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 | ||
− | + | args['header100'] = "Tooltip" | |
− | + | args['data101'] = "{{Infobox | subbox = yes" | |
− | + | args['bodystyle'] = "padding: 0.5em; margin:auto; font-style:italic; font-size:110%; text-align: center" | |
− | + | args['data1'] = item['extraTooltipInfo'] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
return require('Module:Infobox')['infobox'](args) | return require('Module:Infobox')['infobox'](args) | ||
Line 553: | Line 224: | ||
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 |