]> git.lizzy.rs Git - Crafter.git/blobdiff - mods/itemhandling/magnet.lua
Fix name put in wrong place
[Crafter.git] / mods / itemhandling / magnet.lua
index a93cdc03b4689ea8951afbc4b0322506fd146dc0..9a9d7372939d4db207cf6a8769398697e971c50d 100644 (file)
@@ -23,8 +23,8 @@ local entity
 local tick = false
 local function magnet(player)
        --don't magnetize to dead players
+       name = player:get_player_name()
        if player:get_hp() > 0 then
-               name = player:get_player_name()
                pos = player:get_pos()
                inv = player:get_inventory()
                if tick == true and pool[name] > 0 then
@@ -33,7 +33,11 @@ local function magnet(player)
                                gain = 0.4,
                                pitch = math.random(60,100)/100
                        })
-                       pool[name] = pool[name] - 1
+                       if pool[name] > 6 then
+                               pool[name] = 6
+                       else
+                               pool[name] = pool[name] - 1
+                       end
                end
                --radial detection
                for _,object in ipairs(minetest.get_objects_inside_radius({x=pos.x,y=pos.y+0.5,z=pos.z}, 2)) do