summaryrefslogtreecommitdiff
path: root/tubes.lua
diff options
context:
space:
mode:
authorhdastwb <hdastwb@hdastwb.heliohost.org>2013-07-08 12:06:47 -0400
committerhdastwb <hdastwb@hdastwb.heliohost.org>2013-07-13 21:16:44 -0400
commit31680fcf80c841679c3c8c59143a1a91aa4d7922 (patch)
treea08dcda353cbd80f1411ecd0902b1ccd43c243e1 /tubes.lua
parentb19b57ef4b9625f5e1542d7c7aef557a8abf66d5 (diff)
downloadpipeworks-31680fcf80c841679c3c8c59143a1a91aa4d7922.tar
pipeworks-31680fcf80c841679c3c8c59143a1a91aa4d7922.tar.gz
pipeworks-31680fcf80c841679c3c8c59143a1a91aa4d7922.tar.bz2
pipeworks-31680fcf80c841679c3c8c59143a1a91aa4d7922.tar.xz
pipeworks-31680fcf80c841679c3c8c59143a1a91aa4d7922.zip
added more powerful sand tubes (MESE sand tubes), along with associated crafts, textures, and documentation
Diffstat (limited to 'tubes.lua')
-rw-r--r--tubes.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/tubes.lua b/tubes.lua
index 0a91a26..dc1e95a 100644
--- a/tubes.lua
+++ b/tubes.lua
@@ -518,3 +518,62 @@ minetest.register_abm({nodenames={"group:sand_tube"},interval=1,chance=1,
end
})
+mese_sand_noctr_textures={"pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png",
+ "pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png","pipeworks_mese_sand_tube_noctr.png"}
+mese_sand_plain_textures={"pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png",
+ "pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png","pipeworks_mese_sand_tube_plain.png"}
+mese_sand_end_textures={"pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png",
+ "pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png","pipeworks_mese_sand_tube_end.png"}
+mese_sand_short_texture="pipeworks_mese_sand_tube_short.png"
+mese_sand_inv_texture="pipeworks_mese_sand_tube_inv.png"
+
+register_tube("pipeworks:mese_sand_tube","Mese sand pneumatic tube segment",mese_sand_plain_textures,mese_sand_noctr_textures,mese_sand_end_textures,
+ mese_sand_short_texture,mese_sand_inv_texture,
+ {groups={mese_sand_tube=1},
+ on_construct = function(pos)
+ local meta = minetest.env:get_meta(pos)
+ meta:set_int("dist", 0)
+ meta:set_string("formspec",
+ "size[2,1]"..
+ "field[.5,.5;1.5,1;dist;distance;${dist}]")
+ meta:set_string("infotext", "Mese sand pneumatic tube")
+ end,
+ on_receive_fields=function(pos,formname,fields,sender)
+ local meta=minetest.env:get_meta(pos)
+ local dist
+ _, dist = pcall(tonumber, fields.dist)
+ if dist and 0 <= dist and dist <= 8 then meta:set_int("dist", dist) end
+ end,
+})
+
+local function get_objects_with_square_radius(pos, rad)
+ rad = rad + .5;
+ local objs = {}
+ for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, math.sqrt(3)*rad)) do
+ if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
+ local opos = object:getpos()
+ if pos.x - rad <= opos.x and opos.x <= pos.x + rad and pos.y - rad <= opos.y and opos.y <= pos.y + rad and pos.z - rad <= opos.z and opos.z <= pos.z + rad then
+ objs[#objs + 1] = object
+ end
+ end
+ end
+ return objs
+end
+
+minetest.register_abm({nodenames={"group:mese_sand_tube"},interval=1,chance=1,
+ action=function(pos, node, active_object_count, active_object_count_wider)
+ for _,object in ipairs(get_objects_with_square_radius(pos, minetest.env:get_meta(pos):get_int("dist"))) 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.01,y=1,z=-0.01})
+ titem:setacceleration({x=0, y=0, z=0})
+ end
+ object:get_luaentity().itemstring = ""
+ object:remove()
+ end
+ end
+ end
+})
+