Skip to content

Commit

Permalink
Added functions from vector_extras to nether mod.
Browse files Browse the repository at this point in the history
Thanks @paramat.
Fixes HybridDog#7
In theory, needs testing.
  • Loading branch information
Megaf committed Dec 20, 2017
1 parent d32ede7 commit 43bf496
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions nether/init.lua
Expand Up @@ -691,10 +691,40 @@ function nether.grow_netherstructure(pos, generated)
set_vm_data(manip, nodes, pos, t1, "blood", generated)
end

local function set(tab, z,y,x, data)
if tab[z] then
if tab[z][y] then
tab[z][y][x] = data
return
end
tab[z][y] = {[x] = data}
return
end
tab[z] = {[y] = {[x] = data}}
end

local function get(tab, z,y,x)
local data = tab[z]
if data then
data = data[y]
if data then
return data[x]
end
end
end

local set = vector.set_data_to_pos
local get = vector.get_data_from_pos
local remove = vector.remove_data_from_pos
local function remove(tab, z,y,x)
if vector.get_data_from_pos(tab, z,y,x) == nil then

This comment has been minimized.

Copy link
@paramat

paramat Dec 20, 2017

if get(tab, z,y,x) == nil then

return
end
tab[z][y][x] = nil
if not next(tab[z][y]) then
tab[z][y] = nil
end
if not next(tab[z]) then
tab[z] = nil
end
end

local function soft_node(id)
return id == c.air or id == c.ignore
Expand Down

0 comments on commit 43bf496

Please sign in to comment.