mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-05-21 06:43:17 -04:00
Fix moontest:air not disappearing in vacuum
Edited airgen to generate all air at once. Changed air ABM to disappear when next to vacuum, not spread.
This commit is contained in:
parent
cfff19a4f1
commit
228ff22996
2 changed files with 55 additions and 29 deletions
|
@ -119,36 +119,45 @@ minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Air spreads
|
-- Air dies
|
||||||
|
--this is the hackiest code I've ever written
|
||||||
|
-- If neighbors worked as I would like it to, this wouldn't be necessary...
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = {"moontest:air"},
|
nodenames = {"moontest:air"},
|
||||||
neighbors = {"moontest:vacuum", "air"},
|
neighbors = {"moontest:vacuum"},
|
||||||
interval = 11,
|
interval = 1,
|
||||||
chance = 9,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local spread = minetest.get_meta(pos):get_int("spread")
|
|
||||||
if spread <= 0 then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local x = pos.x
|
local x = pos.x
|
||||||
local y = pos.y
|
local y = pos.y
|
||||||
local z = pos.z
|
local z = pos.z
|
||||||
for i = -1,1 do
|
--adjacent node positions
|
||||||
for j = -1,1 do
|
local left = {x=x-1,y=y,z=z}
|
||||||
for k = -1,1 do
|
local right = {x=x+1,y=y,z=z}
|
||||||
if not (i == 0 and j == 0 and k == 0) then
|
local up = {x=x,y=y+1,z=z}
|
||||||
local nodename = minetest.get_node({x=x+i,y=y+j,z=z+k}).name
|
local down = {x=x,y=y-1,z=z}
|
||||||
if nodename == "moontest:vacuum"
|
local forward = {x=x,y=y,z=z+1}
|
||||||
or nodename == "air" then
|
local back = {x=x,y=y,z=z-1}
|
||||||
minetest.add_node({x=x+i,y=y+j,z=z+k},{name="moontest:air"})
|
--cross references those for vacuum, spread if true
|
||||||
minetest.get_meta({x=x+i,y=y+j,z=z+k}):set_int("spread", (spread - 1))
|
if minetest.get_node(left).name == "moontest:vacuum" then
|
||||||
print ("[moontest] MR air spreads "..(spread - 1))
|
minetest.set_node(pos, {name="moontest:vacuum"})
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
if minetest.get_node(right).name == "moontest:vacuum" then
|
||||||
|
minetest.set_node(pos, {name="moontest:vacuum"})
|
||||||
end
|
end
|
||||||
|
if minetest.get_node(up).name == "moontest:vacuum" then
|
||||||
|
minetest.set_node(pos, {name="moontest:vacuum"})
|
||||||
end
|
end
|
||||||
|
if minetest.get_node(down).name == "moontest:vacuum" then
|
||||||
|
minetest.set_node(pos, {name="moontest:vacuum"})
|
||||||
|
end
|
||||||
|
if minetest.get_node(forward).name == "moontest:vacuum" then
|
||||||
|
minetest.set_node(pos, {name="moontest:vacuum"})
|
||||||
|
end
|
||||||
|
if minetest.get_node(back).name == "moontest:vacuum" then
|
||||||
|
minetest.set_node(pos, {name="moontest:vacuum"})
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -78,21 +78,38 @@ minetest.register_node("moontest:airgen", {
|
||||||
local x = pos.x
|
local x = pos.x
|
||||||
local y = pos.y
|
local y = pos.y
|
||||||
local z = pos.z
|
local z = pos.z
|
||||||
for i = -1,1 do
|
--fire up the voxel manipulator
|
||||||
for j = -1,1 do
|
local vm = minetest.get_voxel_manip()
|
||||||
for k = -1,1 do
|
local p1 = {x=x-16,y=y-16,z=z-16}
|
||||||
|
local p2 = {x=x+16,y=y+16,z=z+16}
|
||||||
|
pmin, pmax = vm:read_from_map(p1,p2)
|
||||||
|
local area = VoxelArea:new{MinEdge=pmin, MaxEdge=pmax}
|
||||||
|
local data = vm:get_data()
|
||||||
|
|
||||||
|
local c_vac = minetest.get_content_id("moontest:vacuum")
|
||||||
|
local c_gair = minetest.get_content_id("moontest:air")
|
||||||
|
|
||||||
|
for i = -16,16 do
|
||||||
|
for j = -16,16 do
|
||||||
|
for k = -16,16 do
|
||||||
if not (i == 0 and j == 0 and k == 0) then
|
if not (i == 0 and j == 0 and k == 0) then
|
||||||
local nodename = minetest.get_node({x=x+i,y=y+j,z=z+k}).name
|
if i*i+j*j+k*k <= 16 * 16 + 16 then
|
||||||
if nodename == "moontest:vacuum" then
|
--grab the location of the node in question
|
||||||
minetest.add_node({x=x+i,y=y+j,z=z+k},{name="moontest:air"})
|
local vi = area:index(x+i, y+j, z+k)
|
||||||
minetest.get_meta({x=x+i,y=y+j,z=z+k}):set_int("spread", 16)
|
--if it's vacuum, it won't be now!
|
||||||
print ("[moontest] Added MR air node")
|
if data[vi] == c_vac then
|
||||||
|
data[vi] = c_gair
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--write the voxel manipulator data back to world
|
||||||
|
vm:set_data(data)
|
||||||
|
vm:write_to_map(data)
|
||||||
|
vm:update_map()
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue