Editing Module:Infobox Recipe
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 8: | Line 8: | ||
local album_xp_data = mw.loadData('Module:Experience/data').album |
local album_xp_data = mw.loadData('Module:Experience/data').album |
||
local lang = mw.language.getContentLanguage() |
local lang = mw.language.getContentLanguage() |
||
local tooltip = require('Module:Tooltip') |
|||
local function formatNum(n) |
local function formatNum(n) |
||
Line 28: | Line 27: | ||
--If set to true, will check if any of the items passed as a rawmaterialparam are actually intermediate materials. Will then change the display order of the infobox. |
--If set to true, will check if any of the items passed as a rawmaterialparam are actually intermediate materials. Will then change the display order of the infobox. |
||
local showFullRecipe = yn(args.showFull or 'no', false) |
local showFullRecipe = yn(args.showFull or 'no', false) |
||
--If set to true, will check hide the album xp section as the item does not give album xp. |
|||
local hideAlbum = yn(args.hideAlbum or 'no', false) |
|||
--Checks if the recipe has been flagged as passive, defaults to no. |
|||
local passive = yn(args.passive or 'no', false) |
|||
--Get each of the rawmatX parameters from params and store their values in a new table |
--Get each of the rawmatX parameters from params and store their values in a new table |
||
local argsMaterials = p._extractRawMaterials(args) |
local argsMaterials = p._extractRawMaterials(args) |
||
Line 77: | Line 70: | ||
['Recipe JSON'] = mw.text.jsonEncode({ |
['Recipe JSON'] = mw.text.jsonEncode({ |
||
facility = args.facility, |
|||
xp = args.exp and tonumber(args.exp), |
xp = args.exp and tonumber(args.exp), |
||
kp = args.kp and tonumber(args.kp), |
kp = args.kp and tonumber(args.kp), |
||
duration = args.duration |
duration = args.duration, |
||
materials = argsMaterials, |
materials = argsMaterials, |
||
profession = args.profession, |
profession = args.profession, |
||
passive = passive, |
|||
level = args.level and tonumber(args.level), |
level = args.level and tonumber(args.level), |
||
-- Make sure to update this when multiple outputs are supported |
-- Make sure to update this when multiple outputs are supported |
||
Line 109: | Line 100: | ||
-- display XP and duration totals for multi-step process |
-- display XP and duration totals for multi-step process |
||
args. |
args.displayXP = tonumber(args.exp) and searchResult.xp and searchResult.xp + tonumber(args.exp) |
||
args.displayDuration = tonumber(args.duration) and searchResult.duration and searchResult.duration + tonumber(args.duration) |
args.displayDuration = tonumber(args.duration) and searchResult.duration and searchResult.duration + tonumber(args.duration) |
||
Line 115: | Line 106: | ||
rawMaterials = argsMaterials |
rawMaterials = argsMaterials |
||
end |
end |
||
--If it is a passive recipe, will want to display the per-hour values for XP and materials used |
|||
args.recipePerHour = args.duration and math.floor(3600/args.duration) |
|||
args.displayXP = (tonumber(args.exp) and args.recipePerHour and tonumber(args.exp) * args.recipePerHour) or '' |
|||
args.displayOutput1qty = (args.output1qty and args.recipePerHour and args.output1qty * args.recipePerHour) or '' |
|||
--Simple query to get the shop buy price for the provided material, if no buy price is available returns 0 |
--Simple query to get the shop buy price for the provided material, if no buy price is available returns 0 |
||
Line 152: | Line 138: | ||
local materialBuyPrice = getBuyPrice(item) * (item.quantity or 1) |
local materialBuyPrice = getBuyPrice(item) * (item.quantity or 1) |
||
rawMaterialCost = rawMaterialCost + materialBuyPrice |
rawMaterialCost = rawMaterialCost + materialBuyPrice |
||
local displayQuantity = item.quantity or 1 |
|||
if passive then |
|||
displayQuantity = displayQuantity and args.recipePerHour and displayQuantity * args.recipePerHour |
|||
end |
|||
return mw.html.create('tr') |
return mw.html.create('tr') |
||
:tag('td') |
:tag('td') |
||
Line 168: | Line 150: | ||
:css{ ['text-align'] = 'right' } |
:css{ ['text-align'] = 'right' } |
||
:wikitext(item.quantity or 1) |
:wikitext(item.quantity or 1) |
||
⚫ | |||
:wikitext('<br>( ' .. displayQuantity .. ' per hour)' ) |
|||
⚫ | |||
:done() |
:done() |
||
:node(currency_cell(materialBuyPrice)) |
:node(currency_cell(materialBuyPrice)) |
||
Line 225: | Line 204: | ||
:done() |
:done() |
||
:done() |
:done() |
||
: |
:IF(not args.quest) |
||
:tag(' |
:tag('tr') |
||
: |
:tag('th') |
||
⚫ | |||
⚫ | |||
:wikitext('[[File:Passive small icon.png|20x20px|link=Passive Activity]] [[Passive Activity|Passive]] [[Experience]] ') |
|||
:node(tooltip._span{ 'passive' }) |
|||
:node(tooltip._div{ name = 'passive', content = 'Passive activities give reduced experience when a players level is high enough to perform a new passive activity for that profession. The number shown here is the full experience.' }) |
|||
⚫ | |||
:wikitext('[[Experience]]') |
:wikitext('[[Experience]]') |
||
: |
:done() |
||
⚫ | |||
:attr{ colspan = '11' } |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
:done() |
:done() |
||
:END() |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
:wikitext(hc(args.fullXP) and (formatNum(tonumber(args.fullXP))) or ("'''?'''")) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
:tag('tr') |
:tag('tr') |
||
:tag('th') |
:tag('th') |
||
Line 276: | Line 246: | ||
:wikitext('Level') |
:wikitext('Level') |
||
:done() |
:done() |
||
: |
:IF(not args.quest) |
||
: |
:tag('th') |
||
:attr{ colspan = '5' } |
|||
:wikitext('[[Knowledge|KP]]') |
:wikitext('[[Knowledge|KP]]') |
||
⚫ | |||
: |
:done() |
||
: |
:tag('th') |
||
:attr{ colspan = '5' } |
|||
:wikitext('[[Album|Album XP]] ') |
|||
: |
:wikitext('[[Album|Album XP]]') |
||
⚫ | |||
:node(tooltip._div{ name = 'album', content = 'Album XP is a bonus awarded once for the first time the activity is performed.' }) |
|||
: |
:ELSE() |
||
⚫ | |||
:attr{ colspan = '10' } |
|||
⚫ | |||
⚫ | |||
⚫ | |||
:done() |
:done() |
||
:tag('tr') |
:tag('tr') |
||
Line 297: | Line 272: | ||
:wikitext(hc(args.level) and (args.level) or editButton("'''?''' (edit)").. '[[Category:Needs level recipe]]') |
:wikitext(hc(args.level) and (args.level) or editButton("'''?''' (edit)").. '[[Category:Needs level recipe]]') |
||
:done() |
:done() |
||
: |
:IF(not args.quest) |
||
: |
:tag('td') |
||
: |
:attr{ colspan = '5' } |
||
:css{ ['text-align'] = 'center' } |
|||
:wikitext(hc(args.kp) and ('%s%%'):format(args.kp) or editButton("'''?''' (edit)").. '[[Category:Needs knowledge recipe]]') |
:wikitext(hc(args.kp) and ('%s%%'):format(args.kp) or editButton("'''?''' (edit)").. '[[Category:Needs knowledge recipe]]') |
||
:done() |
|||
: |
:done() |
||
: |
:tag('td') |
||
: |
:attr{ colspan = '5' } |
||
:css{ ['text-align'] = 'center' } |
|||
:IF(hideAlbum) |
|||
:wikitext('N/A') |
|||
:ELSE() |
|||
:wikitext(album_xp or 'Unknown') |
:wikitext(album_xp or 'Unknown') |
||
: |
:done() |
||
: |
:ELSE() |
||
⚫ | |||
:attr{ colspan = '10' } |
|||
:css{ ['text-align'] = 'center' } |
|||
⚫ | |||
⚫ | |||
⚫ | |||
:done() |
:done() |
||
Line 402: | Line 380: | ||
:css{ ['text-align'] = 'right' } |
:css{ ['text-align'] = 'right' } |
||
:wikitext(args.output1qty or 1) |
:wikitext(args.output1qty or 1) |
||
:IF(passive) |
|||
:wikitext('<br>( ' .. args.displayOutput1qty .. ' per hour)' ) |
|||
:END() |
|||
:done() |
:done() |
||
:node(currency_cell(output1TotalValue)) |
:node(currency_cell(output1TotalValue)) |
||
Line 447: | Line 422: | ||
return reversed |
return reversed |
||
end |
end |
||
return p |
return p |