Added sand tubes, which take nearby items.
authorNovatux <nathanael.courant@laposte.net>
Sun, 20 Jan 2013 16:29:11 +0000 (17:29 +0100)
committerNovatux <nathanael.courant@laposte.net>
Sun, 20 Jan 2013 16:29:11 +0000 (17:29 +0100)
tubes.lua

index 0061f5add8831212cdb10ed722eb746c950c0baf..ee982e10b18f8e813ec107cf7f57352a9808f910 100644 (file)
--- a/tubes.lua
+++ b/tubes.lua
@@ -423,5 +423,28 @@ register_tube("pipeworks:accelerator_tube","Accelerator pneumatic tube segment",
                        return notvel(meseadjlist,velocity)
                end}})
 
+register_tube("pipeworks:sand_tube","Sand pneumatic tube segment",plain_textures,noctr_textures,end_textures,
+               short_texture,inv_texture,
+               {groups={sand_tube=1},
+               tube={can_go=function(pos,node,velocity,stack)
+                       return meseadjlist
+               end}})
+
+minetest.register_abm({nodenames={"group:sand_tube"},interval=1,chance=1,
+       action=function(pos, node, active_object_count, active_object_count_wider)
+               for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
+                       if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
+                               if object:get_luaentity().itemstring ~= "" then
+                                       local titem=tube_item(pos,object:get_luaentity().itemstring)
+                                       titem:get_luaentity().start_pos = {x=pos.x,y=pos.y-1,z=pos.z}
+                                       titem:setvelocity({x=0,y=1,z=0})
+                                       titem:setacceleration({x=0, y=0, z=0})
+                               end
+                               object:get_luaentity().itemstring = ""
+                               object:remove()
+                       end
+               end
+       end})
+
 modpath=minetest.get_modpath("pipeworks")
 dofile(modpath.."/teleport_tube.lua")
\ No newline at end of file