From 76e77cceb4622fca3775b31b3c0dbce95f393f98 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 14 Feb 2017 04:12:17 +0100 Subject: [PATCH] Place boats and minecarts with dispenser --- mods/redstone/mcl_dispensers/init.lua | 29 ++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/mods/redstone/mcl_dispensers/init.lua b/mods/redstone/mcl_dispensers/init.lua index 4f6e70449..dd48f7958 100644 --- a/mods/redstone/mcl_dispensers/init.lua +++ b/mods/redstone/mcl_dispensers/init.lua @@ -115,7 +115,7 @@ local dispenserdef = { bucket_id = "bucket:bucket_lava" end if collect_liquid then - minetest.swap_node(droppos, {name="air"}) + minetest.set_node(droppos, {name="air"}) -- Fill bucket with liquid and put it back into inventory -- if there's still space. If not, drop it. @@ -170,6 +170,33 @@ local dispenserdef = { inv:set_stack("main", stack_id, stack) end + elseif iname == "mcl_minecarts:minecart" then + -- Place minecart as entity on rail + if dropnodedef.groups.rail then + minetest.add_entity(droppos, "mcl_minecarts:minecart") + + else + -- Drop item + minetest.add_item(droppos, dropitem) + + end + + stack:take_item() + inv:set_stack("main", stack_id, stack) + + elseif igroups.boat then + local below = {x=droppos.x, y=droppos.y-1, z=droppos.z} + local belownode = minetest.get_node(below) + -- Place boat as entity on or in water + if dropnodedef.groups.water or (dropnode.name == "air" and minetest.registered_nodes[belownode.name].groups.water) then + minetest.add_entity(droppos, "mcl_boats:boat") + else + minetest.add_item(droppos, dropitem) + end + + stack:take_item() + inv:set_stack("main", stack_id, stack) + -- TODO: Many other dispenser actions else -- Drop item