Editing Module:StonemasonPassiveList
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 1: | Line 1: | ||
require('strict') |
require('strict') |
||
require('Module:Mw.html extension') |
require('Module:Mw.html extension') |
||
local recipe = require('Module:Infobox Recipe') -- to make use of its extensive material searching function |
|||
local param = require( 'Module:Paramtest' ) |
local param = require( 'Module:Paramtest' ) |
||
local currency = require('Module:Currency') |
local currency = require('Module:Currency') |
||
local discount = require('Module:MerchantHideDiscount') |
|||
local lang = mw.getContentLanguage() |
local lang = mw.getContentLanguage() |
||
Line 77: | Line 79: | ||
local unpackJSON = mw.text.jsonDecode(item.recipeJSON) |
local unpackJSON = mw.text.jsonDecode(item.recipeJSON) |
||
item.outputQuantity = unpackJSON.output[1].quantity |
item.outputQuantity = unpackJSON.output[1].quantity |
||
-- SECTION REMOVED |
|||
-- do not need to extensively search for subrecipes, as passive recipe |
|||
-- passive recipes only ever have one step |
|||
⚫ | |||
-- call the module:infobox recipe to extensively search for |
|||
-- all raw materials (to add to prices) |
|||
-- all intermediate materials (for intermediate XP and duration) |
|||
local Materials = recipe._getTrueRawMaterials(unpackJSON.materials) |
|||
if next(Materials) ~= nil then |
|||
⚫ | |||
item.intermediates = Materials.intermediateMaterials |
|||
end |
|||
-- iterate through materials, adding buy price to running total (individuals not needed) |
-- iterate through materials, adding buy price to running total (individuals not needed) |
||
item.buy = 0 |
item.buy = 0 |
||
Line 100: | Line 106: | ||
item.buy = item.buy and item.buy + shopPrice * material.quantity |
item.buy = item.buy and item.buy + shopPrice * material.quantity |
||
end |
|||
-- iterate through intermediaries to add to XP and duration parameters |
|||
for _, intermediate in ipairs(item.intermediates) do |
|||
-- look up activity XP and add it to running total |
|||
local XPQuery = '[[Recipe output::' .. intermediate.name .. ']]|?Activity XP|mainlabel=' .. intermediate.name |
|||
local XPResult = mw.smw.ask(XPQuery) or {} |
|||
local XPIncrease = 0 |
|||
if XPResult[1] and XPResult[1]["Activity XP"] then |
|||
XPIncrease = tonumber(XPResult[1]["Activity XP"]) or 0 |
|||
else |
|||
XPIncrease = nil |
|||
end |
|||
-- need to look up both the amount of the item used in this recipe and created in its own recipe to know how much of this xp to use |
|||
local QTYused = intermediate.quantity |
|||
local QTYQuery = '[[Recipe output::' .. intermediate.name .. ']]|?Recipe JSON|mainlabel=' .. intermediate.name |
|||
local QTYResult = mw.smw.ask(QTYQuery) or {} |
|||
local QTYmade = 0 |
|||
if QTYResult[1] and QTYResult[1]["Recipe JSON"] then |
|||
QTYmade = mw.text.jsonDecode(QTYResult[1]["Recipe JSON"]) or {} |
|||
end |
|||
QTYmade = QTYmade.output[1].quantity |
|||
item.XP = item.XP and XPIncrease and item.XP + XPIncrease * QTYused / QTYmade; |
|||
-- look up activity duration and add it to running total |
|||
local durationQuery = '[[Recipe output::' .. intermediate.name .. ']]|?Activity duration|mainlabel=' .. intermediate.name |
|||
local durationResult = mw.smw.ask(durationQuery) or {} |
|||
local durationIncrease = 0 |
|||
if durationResult[1] and durationResult[1]["Activity duration"] then |
|||
durationIncrease = tonumber(durationResult[1]["Activity duration"]) or 0 |
|||
else |
|||
durationIncrease = nil |
|||
end |
|||
item.duration = item.duration and durationIncrease and item.duration + durationIncrease * intermediate.quantity |
|||
end |
end |
||
Line 189: | Line 234: | ||
:tag('td') |
:tag('td') |
||
:addClass('plinkt-image no-border') |
:addClass('plinkt-image no-border') |
||
:css{ ['border-left'] = '0', ['padding-left'] = '0' } |
:css{ ['border-left'] = '0', ['padding-left'] = '0' } |
||
:wikitext('[[File:' .. item.name .. '.png|link=' .. item.name .. '|30px]]') |
:wikitext('[[File:' .. item.name .. '.png|link=' .. item.name .. '|30px]]') |
||
:done() |
:done() |
||
Line 202: | Line 247: | ||
for i, _ in ipairs(item.materials) do |
for i, _ in ipairs(item.materials) do |
||
materialCell:wikitext(item.materials[i].quantity .. '× [[File:' .. item.materials[i].name .. '.png| |
materialCell:wikitext(item.materials[i].quantity .. '× [[File:' .. item.materials[i].name .. '.png|30px|link=' .. item.materials[i].name .. ']]' .. '[[' .. item.materials[i].name .. ']]<br>') |
||
end |
end |
||