add conversion routine for cheapie's auto tree taps
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>
Fri, 11 Jul 2014 13:15:37 +0000 (09:15 -0400)
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>
Fri, 11 Jul 2014 13:48:43 +0000 (09:48 -0400)
turns them into nodebreakers with technic taps if auto tree taps are not
defined and if technic tree taps are.

init.lua
legacy.lua [new file with mode: 0644]

index 6964abcf01672a5d83407c214dda78da902c3209..acf867eaf75dc7e5f13128413f7b95a795ac962d 100644 (file)
--- 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 (file)
index 0000000..662e68d
--- /dev/null
@@ -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