Handle both pipeworks APIs
authorZefram <zefram@fysh.org>
Thu, 14 Aug 2014 21:12:53 +0000 (22:12 +0100)
committerNovatux <nathanael.courant@laposte.net>
Fri, 15 Aug 2014 11:23:41 +0000 (13:23 +0200)
The new API function is now renamed to pipeworks.tube_inject_item(),
so use it under that name.  If it is not available, synthesise the new
API in terms of the old one.

technic/init.lua
technic/machines/HV/quarry.lua
technic/machines/other/injector.lua
technic/machines/register/common.lua

index fcd1cd96760f7b692739edc923e3801e84165129..28427dae3be4f2bf4158ae7c5cca8d6b4b1c9384 100644 (file)
@@ -4,6 +4,13 @@
 
 technic = technic or {}
 
+technic.tube_inject_item = pipeworks.tube_inject_item or function (pos, start_pos, velocity, item)
+       local tubed = pipeworks.tube_item(vector.new(pos), item)
+       tubed:get_luaentity().start_pos = vector.new(start_pos)
+       tubed:setvelocity(velocity)
+       tubed:setacceleration(vector.new(0, 0, 0))
+end
+
 local load_start = os.clock()
 local modpath = minetest.get_modpath("technic")
 technic.modpath = modpath
index d75a9e3fae8517a5d37f0686b03f5aad755794cd..10c0ee0d045a382346f392584f9052cf4dc1ee25 100644 (file)
@@ -119,7 +119,7 @@ end
 
 local function send_items(items, pos, node)
        for _, item in pairs(items) do
-               pipeworks.tube_item(pos, pos, vector.new(0, 1, 0), item)
+               technic.tube_inject_item(pos, pos, vector.new(0, 1, 0), item)
        end
 end
 
index 485974c0a6da2f4ec3c21379ad49b09a89672843..eb6398703f5ae8a43f11cf9cfadd19a65488736e 100644 (file)
@@ -13,7 +13,7 @@ local function inject_items (pos)
                                local item0=stack:to_table()
                                if item0 then 
                                        item0["count"] = "1"
-                                       pipeworks.tube_item(pos, pos, vector.new(0, -1, 0), item0)
+                                       technic.tube_inject_item(pos, pos, vector.new(0, -1, 0), item0)
                                        stack:take_item(1)
                                        inv:set_stack("main", i, stack)
                                        return
@@ -28,7 +28,7 @@ local function inject_items (pos)
                                if stack then
                                local item0=stack:to_table()
                                if item0 then 
-                                       pipeworks.tube_item(pos, pos, vector.new(0, -1, 0), item0)
+                                       technic.tube_inject_item(pos, pos, vector.new(0, -1, 0), item0)
                                        stack:clear()
                                        inv:set_stack("main", i, stack)
                                        return
index 366009c0caa9a85dc7774eade59763d868fb2d41..9e847c4b41e02cc4a026ff05ed5304a45c37b819 100644 (file)
@@ -52,7 +52,7 @@ function technic.send_items(pos, x_velocity, z_velocity, output_name)
                        local item0 = stack:to_table()
                        if item0 then 
                                item0["count"] = "1"
-                               pipeworks.tube_item(pos, pos, vector.new(x_velocity, 0, z_velocity), item0)
+                               technic.tube_inject_item(pos, pos, vector.new(x_velocity, 0, z_velocity), item0)
                                stack:take_item(1)
                                inv:set_stack(output_name, i, stack)
                                return