minetest.get_craft_result
Revision as of 19:43, 21 February 2013 by Prestidigitator (talk | contribs) (From lua_api.txt with tested example inputs/outputs)
Syntax
minetest.get_craft_result(input)
Description
input
is a table describing the potential crafting inputs and context. Its fields are:
method
—'normal'
or'cooking'
or'fuel'
.width
— Width of the recipe. A positive integer (e.g. 3).items
— A table of input item stacks, for example:{ stack1, stack2, stack3, stack4, stack5, stack6, stack7, stack8, stack9 }
Returns two output tables, output
and decremented_input
. output
has the following fields:
item
— An ItemStack (empty stack if the call is unsuccessful).time
— A number (0 if the call is unsuccessful).
and decremented_input
is like input
with the recipe inputs removed from the items
stacks.
Example
output, decremented_input = minetest.get_craft_result({ method = "normal", width = 1, items = { ItemStack("default:coal_lump 2"), ItemStack("default:stick 2") }})
-- output.item:to_table() = {wear = 0, name = "default:torch", count = 4, metadata = ""}
-- output.time = 0
-- decremented_input.method = "normal"
-- decremented_input.width = 1
-- #decremented_input.items = 2
-- decremented_input.items[1]:to_table() = {wear = 0, name = "default:coal_lump", count = 1, metadata = ""}
-- decremented_input.items[2]:to_table() = {wear = 0, name = "default:stick", count = 1, metadata = ""}