aboutsummaryrefslogtreecommitdiff
path: root/games/minimal
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-06-02 12:19:44 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-06-03 22:31:01 +0300
commit353f9fd43c94b6d046c077ccfa25320dfe93cfe6 (patch)
tree4ce4cc4f25cfac504a6aea2f9c48866ea3d462ce /games/minimal
parent3899f83da879e11cf531c88514772b890d060721 (diff)
downloadminetest-353f9fd43c94b6d046c077ccfa25320dfe93cfe6.tar.gz
minetest-353f9fd43c94b6d046c077ccfa25320dfe93cfe6.tar.bz2
minetest-353f9fd43c94b6d046c077ccfa25320dfe93cfe6.zip
minetest.get_craft_result
Diffstat (limited to 'games/minimal')
-rw-r--r--games/minimal/mods/default/init.lua51
1 files changed, 51 insertions, 0 deletions
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
@@ -1573,6 +1573,57 @@ minetest.register_on_chat_message(function(name, message)
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
--