]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/itemhandling/init.lua
Fix name put in wrong place
[Crafter.git] / mods / itemhandling / init.lua
index cd4d73a635813432eaf59241fbda1c691f199418..eaf33d73ffd420de5f4a6f1f073e23c8f259671c 100644 (file)
@@ -1,4 +1,4 @@
-local minetest,math,vector,pairs,ItemStack = minetest,math,vector,pairs,ItemStack
+local minetest,math,vector,pairs,ItemStack,ipairs = minetest,math,vector,pairs,ItemStack,ipairs
 
 local path = minetest.get_modpath("itemhandling")
 dofile(path.."/magnet.lua")
@@ -186,9 +186,10 @@ local get_staticdata = function(self)
        })
 end
 
+local data
 local on_activate = function(self, staticdata, dtime_s)
        if string.sub(staticdata, 1, string.len("return")) == "return" then
-               local data = minetest.deserialize(staticdata)
+               data = minetest.deserialize(staticdata)
                if data and type(data) == "table" then
                        self.itemstring = data.itemstring
                        self.age = (data.age or 0) + dtime_s
@@ -258,6 +259,7 @@ local vel
 local def
 local slip_factor
 local change
+local slippery
 local item_step = function(self, dtime, moveresult)
        pos = self.object:get_pos()
        if not pos then
@@ -366,7 +368,7 @@ local item_step = function(self, dtime, moveresult)
 
        is_stuck = false
        snode = minetest.get_node_or_nil(pos)
-       if snode ~= "air" then
+       if snode and snode ~= "air" then
                snode = minetest.registered_nodes[snode.name] or {}
                is_stuck = (snode.walkable == nil or snode.walkable == true)
                        and (snode.collision_box == nil or snode.collision_box.type == "regular")