summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2014-07-11 09:15:37 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2014-07-11 09:48:43 -0400
commit8aea4b1a1364e0cb6c4bb7b344c5b83455ed4bb5 (patch)
tree61208fea2e153ca1d172dcbdcd21029deadad102
parent87d87c91fa83a8bdb09e718f0641a33f475f6826 (diff)
add conversion routine for cheapie's auto tree taps
turns them into nodebreakers with technic taps if auto tree taps are not defined and if technic tree taps are.
-rw-r--r--init.lua6
-rw-r--r--legacy.lua59
2 files changed, 64 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 6964abc..acf867e 100644
--- a/init.lua
+++ b/init.lua
@@ -120,7 +120,11 @@ if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua")
if pipeworks.enable_redefines then dofile(pipeworks.modpath.."/compat.lua") end
if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end
if pipeworks.enable_deployer then dofile(pipeworks.modpath.."/deployer.lua") end
-if pipeworks.enable_node_breaker then dofile(pipeworks.modpath.."/node_breaker.lua") end
+
+if pipeworks.enable_node_breaker then
+ dofile(pipeworks.modpath.."/node_breaker.lua")
+ dofile(pipeworks.modpath.."/legacy.lua")
+end
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
diff --git a/legacy.lua b/legacy.lua
new file mode 100644
index 0000000..662e68d
--- /dev/null
+++ b/legacy.lua
@@ -0,0 +1,59 @@
+
+if not minetest.get_modpath("auto_tree_tap") and
+ minetest.get_modpath("technic") then
+
+ minetest.register_abm({
+ nodenames = { "auto_tree_tap:off", "auto_tree_tap:on" },
+ chance = 1,
+ interval = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ local fdir = node.param2
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ inv:set_size("pick", 1)
+ inv:set_size("ghost_pick", 1)
+ inv:set_size("main", 100)
+ minetest.set_node(pos, {name = "pipeworks:nodebreaker_off", param2 = fdir})
+ inv:set_stack("pick", 1, ItemStack("technic:treetap"))
+ end
+ })
+
+ minetest.register_node(":auto_tree_tap:off", {
+ description = "Auto-Tap",
+ tiles = {"pipeworks_nodebreaker_top_off.png","pipeworks_nodebreaker_bottom_off.png","pipeworks_nodebreaker_side2_off.png","pipeworks_nodebreaker_side1_off.png",
+ "pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"},
+ is_ground_content = true,
+ paramtype2 = "facedir",
+ groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1},
+ mesecons= {effector={rules=pipeworks.rules_all,action_on=node_breaker_on, action_off=node_breaker_off}},
+ sounds = default.node_sound_stone_defaults(),
+ tube = {connect_sides={back=1}},
+ on_construct = function(pos)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ inv:set_size("pick", 1)
+ inv:set_stack("pick", 1, ItemStack("default:pick_mese"))
+ end,
+ after_place_node = function (pos, placer)
+ pipeworks.scan_for_tube_objects(pos, placer)
+ local placer_pos = placer:getpos()
+
+ --correct for the player's height
+ if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
+
+ --correct for 6d facedir
+ if placer_pos then
+ local dir = {
+ x = pos.x - placer_pos.x,
+ y = pos.y - placer_pos.y,
+ z = pos.z - placer_pos.z
+ }
+ local node = minetest.get_node(pos)
+ node.param2 = minetest.dir_to_facedir(dir, true)
+ minetest.set_node(pos, node)
+ minetest.log("action", "real (6d) facedir: " .. node.param2)
+ end
+ end,
+ after_dig_node = pipeworks.scan_for_tube_objects,
+ })
+end