Module:Sandbox/User:The Gaffer/Modules/Infobox Recipe: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
The Gaffer (talk | contribs) No edit summary |
The Gaffer (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
local p = {} |
local p = {} |
||
function p. |
function p.main(frame) |
||
local args = frame.args |
local args = frame.args |
||
local mw = require('mw') |
local mw = require('mw') |
||
Line 15: | Line 15: | ||
local rawmat1cost = args.rawmat1 and mw.smw.ask('[[:+]][[Sold item::' .. args.rawmat1 .. ']]|?Shop buy price|sort=Shop buy price|order=asc|limit=1') or "0" |
local rawmat1cost = args.rawmat1 and mw.smw.ask('[[:+]][[Sold item::' .. args.rawmat1 .. ']]|?Shop buy price|sort=Shop buy price|order=asc|limit=1') or "0" |
||
mw.logObject(rawmat1cost) |
|||
local rawmat2cost = args.rawmat2 and mw.smw.ask('[[:+]][[Sold item::' .. args.rawmat2 .. ']]|?Shop buy price|sort=Shop buy price|order=asc|limit=1') or "0" |
local rawmat2cost = args.rawmat2 and mw.smw.ask('[[:+]][[Sold item::' .. args.rawmat2 .. ']]|?Shop buy price|sort=Shop buy price|order=asc|limit=1') or "0" |
||
local rawmat3cost = args.rawmat3 and mw.smw.ask('[[:+]][[Sold item::' .. args.rawmat3 .. ']]|?Shop buy price|sort=Shop buy price|order=asc|limit=1') or "0" |
local rawmat3cost = args.rawmat3 and mw.smw.ask('[[:+]][[Sold item::' .. args.rawmat3 .. ']]|?Shop buy price|sort=Shop buy price|order=asc|limit=1') or "0" |
||
Line 90: | Line 89: | ||
table.insert(out, '| style="text-align: right;" | ' .. profit) |
table.insert(out, '| style="text-align: right;" | ' .. profit) |
||
table.insert(out, '|}') |
table.insert(out, '|}') |
||
-- Add debug information to the output using mw.messageBox |
|||
local debugMessage = 'Debug Info:\n' .. |
|||
'rawmat1query: ' .. (rawmat1query or 'nil') .. '\n' .. |
|||
'rawmat1cost: ' .. tostring(rawmat1cost) .. '\n' .. |
|||
'rawmat2query: ' .. (rawmat2query or 'nil') .. '\n' .. |
|||
'rawmat2cost: ' .. tostring(rawmat2cost) .. '\n' .. |
|||
'rawmat3query: ' .. (rawmat3query or 'nil') .. '\n' .. |
|||
'rawmat3cost: ' .. tostring(rawmat3cost) .. '\n' .. |
|||
'totalCost: ' .. tostring(totalCost) .. '\n' .. |
|||
'output1query: ' .. (output1query or 'nil') .. '\n' .. |
|||
'output1cost: ' .. tostring(output1cost) .. '\n' .. |
|||
'output1costTotal: ' .. tostring(output1costTotal) .. '\n' .. |
|||
'profit: ' .. tostring(profit) |
|||
table.insert(out, frame:preprocess('{{#invoke:Message box|mbox|text=' .. debugMessage .. '}}')) |
|||
return table.concat(out, '\n') |
return table.concat(out, '\n') |