Rename tube_item() to tube_inject_item()
authorZefram <zefram@fysh.org>
Thu, 14 Aug 2014 20:59:15 +0000 (21:59 +0100)
committerNovatux <nathanael.courant@laposte.net>
Fri, 15 Aug 2014 11:24:52 +0000 (13:24 +0200)
The new function has no API compatibility with the old one, so give it
a different name to avoid confusion among caller mods, which need to
change their usage.  Have a function under the old name that outputs a
helpful error message.

item_transport.lua
tubes.lua
wielder.lua

index 3e0f3b82d684272c299d3d88790353c3518f97e2..02ef5f864784a356f1ea30e58f74934f212f28a7 100755 (executable)
@@ -4,7 +4,11 @@ local fakePlayer = {
     -- perhaps a custom metaclass that errors specially when fakePlayer.<property> is not found?
 }
 
-function pipeworks.tube_item(pos, start_pos, velocity, item)
+function pipeworks.tube_item(pos, item)
+       error("obsolete pipeworks.tube_item() called; change caller to use pipeworks.tube_inject_item() instead")
+end
+
+function pipeworks.tube_inject_item(pos, start_pos, velocity, item)
        -- Take item in any format
        local stack = ItemStack(item)
        local obj = luaentity.add_entity(pos, "pipeworks:tubed_item")
@@ -112,7 +116,7 @@ local function grabAndFire(data,slotseq_mode,filtmeta,frominv,frominvname,frompo
                                end
                                local pos = vector.add(frompos, vector.multiply(dir, 1.4))
                                local start_pos = vector.add(frompos, dir)
-                               local item1 = pipeworks.tube_item(pos, start_pos, dir, item)
+                               local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item)
                                return true-- only fire one item, please
                        end
        end
@@ -322,7 +326,7 @@ minetest.register_entity("pipeworks:tubed_item", {
                        return
                end
                local item = minetest.deserialize(staticdata)
-               pipeworks.tube_item(self.object:getpos(), item.start_pos, item.velocity, item.itemstring)
+               pipeworks.tube_inject_item(self.object:getpos(), item.start_pos, item.velocity, item.itemstring)
                self.object:remove()
        end,
 })
index 10a7c64f6d392fdb62d9ca062da066fdc3614fee..e7e35794a04109f1dfcda8c7f2cfcbdad9881820 100755 (executable)
--- a/tubes.lua
+++ b/tubes.lua
@@ -496,7 +496,7 @@ if pipeworks.enable_sand_tube then
                                       for _, object in ipairs(minetest.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
-                                                              pipeworks.tube_item(pos, pos, vector.new(0, 0, 0), object:get_luaentity().itemstring)
+                                                              pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), object:get_luaentity().itemstring)
                                                       end
                                                       object:get_luaentity().itemstring = ""
                                                       object:remove()
@@ -556,7 +556,7 @@ if pipeworks.enable_mese_sand_tube then
                                       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
-                                                              pipeworks.tube_item(pos, pos, vector.new(0, 0, 0), object:get_luaentity().itemstring)
+                                                              pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), object:get_luaentity().itemstring)
                                                       end
                                                       object:get_luaentity().itemstring = ""
                                                       object:remove()
index 4bc9a4f3490af572311fd8d034920dcb261c53e9..3ce73f66c1794083471d0db53d274c1727176365 100644 (file)
@@ -101,7 +101,7 @@ local function wielder_on(data, wielder_pos, wielder_node)
        if data.eject_drops then
                for i, stack in ipairs(inv:get_list("main")) do
                        if not stack:is_empty() then
-                               pipeworks.tube_item(wielder_pos, wielder_pos, dir, stack)
+                               pipeworks.tube_inject_item(wielder_pos, wielder_pos, dir, stack)
                                inv:set_stack("main", i, ItemStack(""))
                        end
                end