move inject_items to top of file (so that it's above the abm that calls it)
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>
Thu, 19 Dec 2013 01:41:08 +0000 (20:41 -0500)
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>
Thu, 19 Dec 2013 01:41:08 +0000 (20:41 -0500)
technic/machines/other/injector.lua

index 205b8b4984ac44181bb69b5e4a5b90cd73ed4128..14bc984038e698acd22803cba2e71c39db6ecc57 100644 (file)
@@ -1,6 +1,50 @@
 
 local S = technic.getter
 
+local function inject_items (pos)
+               local meta=minetest.env:get_meta(pos) 
+               local inv = meta:get_inventory()
+               local mode=meta:get_string("mode")
+               if mode=="single items" then
+                       local i=0
+                       for _,stack in ipairs(inv:get_list("main")) do
+                       i=i+1
+                               if stack then
+                               local item0=stack:to_table()
+                               if item0 then 
+                                       item0["count"]="1"
+                                       local item1=pipeworks.tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
+                                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
+                                       item1:setvelocity({x=0, y=-1, z=0})
+                                       item1:setacceleration({x=0, y=0, z=0})
+                                       stack:take_item(1);
+                                       inv:set_stack("main", i, stack)
+                                       return
+                                       end
+                               end
+                       end
+               end
+               if mode=="whole stacks" then
+                       local i=0
+                       for _,stack in ipairs(inv:get_list("main")) do
+                       i=i+1
+                               if stack then
+                               local item0=stack:to_table()
+                               if item0 then 
+                                       local item1=pipeworks.tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
+                                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
+                                       item1:setvelocity({x=0, y=-1, z=0})
+                                       item1:setacceleration({x=0, y=0, z=0})
+                                       stack:clear()
+                                       inv:set_stack("main", i, stack)
+                                       return
+                                       end
+                               end
+                       end
+               end
+               
+end
+
 minetest.register_craft({
        output = 'technic:injector 1',
        recipe = {
@@ -74,46 +118,3 @@ minetest.register_abm({
        end,
 })
 
-local function inject_items (pos)
-               local meta=minetest.env:get_meta(pos) 
-               local inv = meta:get_inventory()
-               local mode=meta:get_string("mode")
-               if mode=="single items" then
-                       local i=0
-                       for _,stack in ipairs(inv:get_list("main")) do
-                       i=i+1
-                               if stack then
-                               local item0=stack:to_table()
-                               if item0 then 
-                                       item0["count"]="1"
-                                       local item1=pipeworks.tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
-                                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
-                                       item1:setvelocity({x=0, y=-1, z=0})
-                                       item1:setacceleration({x=0, y=0, z=0})
-                                       stack:take_item(1);
-                                       inv:set_stack("main", i, stack)
-                                       return
-                                       end
-                               end
-                       end
-               end
-               if mode=="whole stacks" then
-                       local i=0
-                       for _,stack in ipairs(inv:get_list("main")) do
-                       i=i+1
-                               if stack then
-                               local item0=stack:to_table()
-                               if item0 then 
-                                       local item1=pipeworks.tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
-                                       item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
-                                       item1:setvelocity({x=0, y=-1, z=0})
-                                       item1:setacceleration({x=0, y=0, z=0})
-                                       stack:clear()
-                                       inv:set_stack("main", i, stack)
-                                       return
-                                       end
-                               end
-                       end
-               end
-               
-end