From 353f9fd43c94b6d046c077ccfa25320dfe93cfe6 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 2 Jun 2012 12:19:44 +0300 Subject: minetest.get_craft_result --- games/minimal/mods/default/init.lua | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'games/minimal/mods/default/init.lua') diff --git a/games/minimal/mods/default/init.lua b/games/minimal/mods/default/init.lua index 603380d5b..fc5eb0953 100644 --- a/games/minimal/mods/default/init.lua +++ b/games/minimal/mods/default/init.lua @@ -1572,6 +1572,57 @@ minetest.register_on_chat_message(function(name, message) end end) +-- +-- Test some things +-- + +local function test_get_craft_result() + print("test_get_craft_result()") + -- normal + local input = { + method = "normal", + width = 2, + items = {"", "default:coal_lump", "", "default:stick"} + } + print("torch crafting input: "..dump(input)) + local output, decremented_input = minetest.get_craft_result(input) + print("torch crafting output: "..dump(output)) + print("torch crafting decremented input: "..dump(decremented_input)) + assert(output.item) + print("torch crafting output.item:to_table(): "..dump(output.item:to_table())) + assert(output.item:get_name() == "default:torch") + assert(output.item:get_count() == 4) + -- fuel + local input = { + method = "fuel", + width = 1, + items = {"default:coal_lump"} + } + print("coal fuel input: "..dump(input)) + local output, decremented_input = minetest.get_craft_result(input) + print("coal fuel output: "..dump(output)) + print("coal fuel decremented input: "..dump(decremented_input)) + assert(output.time) + assert(output.time > 0) + -- cook + local input = { + method = "cooking", + width = 1, + items = {"default:cobble"} + } + print("cobble cooking input: "..dump(output)) + local output, decremented_input = minetest.get_craft_result(input) + print("cobble cooking output: "..dump(output)) + print("cobble cooking decremented input: "..dump(decremented_input)) + assert(output.time) + assert(output.time > 0) + assert(output.item) + print("cobble cooking output.item:to_table(): "..dump(output.item:to_table())) + assert(output.item:get_name() == "default:stone") + assert(output.item:get_count() == 1) +end +test_get_craft_result() + -- -- Done, print some random stuff -- -- cgit v1.2.3