Skip to content

Commit

Permalink
check buildable_to of nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
NatureFreshMilk committed Sep 10, 2019
1 parent fca1994 commit fa085f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
39 changes: 22 additions & 17 deletions is_area_empty.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
local c_air = minetest.get_content_id("air")
local c_ignore = minetest.get_content_id("ignore")

local has_vacuum_mod = minetest.get_modpath("vacuum")
-- TODO: what about ignore?
local buildable_to_nodes = {}

minetest.after(4, function()
local count = 0
for name, node in pairs(minetest.registered_nodes) do
if node.buildable_to then
count = count + 1
local id = minetest.get_content_id(name)
buildable_to_nodes[id] = true
end
end
minetest.log("action", "[jumpdrive] collected " .. count .. " nodes that are buildable_to")
end)


local c_vacuum
if has_vacuum_mod then
c_vacuum = minetest.get_content_id("vacuum:vacuum")
else
c_vacuum = c_air
end

jumpdrive.is_area_empty = function(pos1, pos2)
local manip = minetest.get_voxel_manip()
Expand All @@ -24,19 +29,19 @@ jumpdrive.is_area_empty = function(pos1, pos2)
local index = area:index(x, y, z)
local id = data[index]

if id ~= c_air and id ~= c_vacuum then
-- not air or vacuum
if id == c_ignore then
return false, "Uncharted"
else
return false, "Neither air or vacuum"
end
if id == c_ignore then
return false, "Uncharted"
end

if not buildable_to_nodes[id] then
-- not buildable_to
return false, "Occupied"
end
end
end
end

-- only air and vacuum nodes found
-- only buildable_to nodes found
return true, ""
end

4 changes: 2 additions & 2 deletions move_nodetimers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ minetest.after(4, function()
end
end
minetest.log("action", "[jumpdrive] collected " .. #node_names_with_timer .. " items with node timers")
end);
end)


-- invoked from move.lua
Expand Down Expand Up @@ -39,4 +39,4 @@ jumpdrive.move_nodetimers = function(source_pos1, source_pos2, delta_vector)
end
end

end
end

0 comments on commit fa085f5

Please sign in to comment.