Module:RecipeDetails: Difference between revisions
From IdleOn MMO Wiki
Kiokurashi (talk | contribs) (Created page with "local p = {} local cargo = mw.ext.cargo -- Takes a list of items and an optional iterator for indentation. function p.RecipeBreakdownRecursive(items, i) local indent = i or 1 -- Used to set padding later. local fullTableStruct = { -- inserted as ( indent, itemName, amount ) } for n = 1, #items do -- Should be a max of 4 items per recipe. -- Insert item into fullTableStruct. -- Query smithing table for the recipe and retrieve the ingeredients -- If previous l...") |
Kiokurashi (talk | contribs) mNo edit summary |
||
Line 38: | Line 38: | ||
-- Query smithing table for the recipe and retrieve the ingeredients | -- Query smithing table for the recipe and retrieve the ingeredients | ||
local function getReecipeItems( item ) | local function getReecipeItems( item ) | ||
local ingredients = {} | |||
-- Query | -- Query | ||
local args = { | |||
where = 'AnvilCraft.Item="'.. item ..'"', | |||
orderBy = 'AnvilCraft.Item' | |||
} | |||
local results = cargo.query('AnvilCraft', 'Resource1, Quantity1, Resource2, Quantity2, Resource3, Quantity3, Resource4, Quantity4', args ) | |||
if #results == 0 then return 0 end -- if no results, exit with 0 | |||
local tuple = {} | |||
for n=1, 4 do | |||
if results['Resource'..n] ~= nil then break end -- If an empty cell is encountered, stop processing items. | |||
tuple = {name = results['Resource'..n], amount = results['Quantity'..n]} | |||
ingredients[n] = tuple | |||
end | |||
-- Return table of items and values. | -- Return table of items and values. | ||
return ingredients | |||
end | end | ||
Revision as of 01:43, 26 March 2024
Documentation for this module may be created at Module:RecipeDetails/doc
local p = {}
local cargo = mw.ext.cargo
-- Takes a list of items and an optional iterator for indentation.
function p.RecipeBreakdownRecursive(items, i)
local indent = i or 1 -- Used to set padding later.
local fullTableStruct = {
-- inserted as ( indent, itemName, amount )
}
for n = 1, #items do -- Should be a max of 4 items per recipe.
-- Insert item into fullTableStruct.
-- Query smithing table for the recipe and retrieve the ingeredients
-- If previous line's result is not nil then recursively call this function and increment i.
end
return fullTableStruct
end
local function RecipeBreakdownFormatter(fullList)
local result = ''
local Row = [==[<tr></tr>]==]
-- Format output rows.
-- Concatenate strings together.
return result
end
local function RecipeTotalsFormatter(fullList)
local result = ''
local Row = [==[<tr></tr>]==]
-- Sort list
-- Add same ingrediets together.
-- Format output rows.
-- Concatenate strings together.
return result
end
-- Query smithing table for the recipe and retrieve the ingeredients
local function getReecipeItems( item )
local ingredients = {}
-- Query
local args = {
where = 'AnvilCraft.Item="'.. item ..'"',
orderBy = 'AnvilCraft.Item'
}
local results = cargo.query('AnvilCraft', 'Resource1, Quantity1, Resource2, Quantity2, Resource3, Quantity3, Resource4, Quantity4', args )
if #results == 0 then return 0 end -- if no results, exit with 0
local tuple = {}
for n=1, 4 do
if results['Resource'..n] ~= nil then break end -- If an empty cell is encountered, stop processing items.
tuple = {name = results['Resource'..n], amount = results['Quantity'..n]}
ingredients[n] = tuple
end
-- Return table of items and values.
return ingredients
end
function p.builder( frame )
local item = frame.args[1]
-- build the data and store it in the table.
end
function p.Main( frame )
-- Query smithing table for the recipe and retrieve the ingeredients
-- return table data for item
end
return p