]> git.lizzy.rs Git - Crafter.git/commitdiff
Stop redstone pool from leaking memory
authoroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 27 Jun 2020 10:04:35 +0000 (06:04 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Sat, 27 Jun 2020 10:04:35 +0000 (06:04 -0400)
mods/redstone/init.lua
mods/redstone/torch.lua

index 2a0e0b070bed4736a6a4b6c51c63329f603e70e5..3a10b53223890491dac1e6a16b5ae29b1b071d0a 100644 (file)
@@ -99,13 +99,13 @@ local function data_injection(pos,data)
                if pool and pool[pos.x] and pool[pos.x][pos.y] then
                        pool[pos.x][pos.y][pos.z] = data
                        
-                       --if not pool[pos.x][pos.y] then
-                       --      pool[pos.x][pos.y] = nil
-                       --      -- only run this if y axis is empty
-                       --      if not pool[pos.x] then
-                       --              pool[pos.x] = nil
-                       --      end
-                       --end
+                       if pool[pos.x][pos.y] and not next(pool[pos.x][pos.y]) then
+                               pool[pos.x][pos.y] = nil
+                               -- only run this if y axis is empty
+                               if pool[pos.x] and not next(pool[pos.x]) then
+                                       pool[pos.x] = nil
+                               end
+                       end
                end
        end
 end
@@ -185,7 +185,6 @@ local boundary
 local function calculate(pos)
 
        boundary = create_boundary_box(pos)
-       --print(dump(boundary))
 
        --pathfind through memory map   
        for x,index_x in pairs(boundary) do
index 1590284f221d1b3d7d0b9331a67c8d68c9a0416f..6cd222bfe05a20b251898ca91f8de7c32ec09edf 100644 (file)
@@ -1,60 +1,5 @@
 local minetest,vector = minetest,vector
 
-
---add in smoke and fire
-local function create_ps(pos)
-       local dir = get_offset(minetest.get_node(pos).param2)
-       local ppos = vector.add(dir,pos)
-       local meta = minetest.get_meta(pos)
-       local psf = minetest.add_particlespawner({
-               amount = 2,
-               time = 0,
-               minpos = ppos,
-               maxpos = ppos,
-               minvel = vector.new(0,0,0),
-               maxvel = vector.new(0,0,0),
-               minacc = {x=0, y=0, z=0},
-               maxacc = {x=0, y=0, z=0},
-               minexptime = 1,
-               maxexptime = 1,
-               minsize = 3,
-               maxsize = 3,
-               collisiondetection = false,
-               vertical = true,
-               texture = "redstone_torch_animated.png",
-               animation = {type = "vertical_frames",
-
-                       aspect_w = 16,
-                       -- Width of a frame in pixels
-
-                       aspect_h = 16,
-                       -- Height of a frame in pixels
-
-                       length =  0.2,
-                       -- Full loop length
-               },
-       })
-       local pss = minetest.add_particlespawner({
-               amount = 2,
-               time = 0,
-               minpos = ppos,
-               maxpos = ppos,
-               minvel = vector.new(-0.1,0.1,-0.1),
-               maxvel = vector.new(0.1,0.3,0.1),
-               minacc = vector.new(0,0,0),
-               maxacc = vector.new(0,0,0),
-               minexptime = 1,
-               maxexptime = 2,
-               minsize = 1,
-               maxsize = 2,
-               collisiondetection = false,
-               vertical = false,
-               texture = "smoke.png",
-       })
-       meta:set_int("psf", psf)
-       meta:set_int("pss", pss)
-end
-
 -- Item definitions
 minetest.register_craftitem("redstone:torch", {
        description = "Redstone Torch",