mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-05-20 22:33:16 -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)
|
||||
|
||||
-- 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({
|
||||
nodenames = {"moontest:air"},
|
||||
neighbors = {"moontest:vacuum", "air"},
|
||||
interval = 11,
|
||||
chance = 9,
|
||||
neighbors = {"moontest:vacuum"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
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 y = pos.y
|
||||
local z = pos.z
|
||||
for i = -1,1 do
|
||||
for j = -1,1 do
|
||||
for k = -1,1 do
|
||||
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 nodename == "moontest:vacuum"
|
||||
or nodename == "air" then
|
||||
minetest.add_node({x=x+i,y=y+j,z=z+k},{name="moontest:air"})
|
||||
minetest.get_meta({x=x+i,y=y+j,z=z+k}):set_int("spread", (spread - 1))
|
||||
print ("[moontest] MR air spreads "..(spread - 1))
|
||||
--adjacent node positions
|
||||
local left = {x=x-1,y=y,z=z}
|
||||
local right = {x=x+1,y=y,z=z}
|
||||
local up = {x=x,y=y+1,z=z}
|
||||
local down = {x=x,y=y-1,z=z}
|
||||
local forward = {x=x,y=y,z=z+1}
|
||||
local back = {x=x,y=y,z=z-1}
|
||||
--cross references those for vacuum, spread if true
|
||||
if minetest.get_node(left).name == "moontest:vacuum" then
|
||||
minetest.set_node(pos, {name="moontest:vacuum"})
|
||||
end
|
||||
if minetest.get_node(right).name == "moontest:vacuum" then
|
||||
minetest.set_node(pos, {name="moontest:vacuum"})
|
||||
end
|
||||
if minetest.get_node(up).name == "moontest:vacuum" then
|
||||
minetest.set_node(pos, {name="moontest:vacuum"})
|
||||
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
|
||||
})
|
||||
|
||||
|
|
|
@ -78,21 +78,38 @@ minetest.register_node("moontest:airgen", {
|
|||
local x = pos.x
|
||||
local y = pos.y
|
||||
local z = pos.z
|
||||
for i = -1,1 do
|
||||
for j = -1,1 do
|
||||
for k = -1,1 do
|
||||
--fire up the voxel manipulator
|
||||
local vm = minetest.get_voxel_manip()
|
||||
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
|
||||
local nodename = minetest.get_node({x=x+i,y=y+j,z=z+k}).name
|
||||
if nodename == "moontest:vacuum" then
|
||||
minetest.add_node({x=x+i,y=y+j,z=z+k},{name="moontest:air"})
|
||||
minetest.get_meta({x=x+i,y=y+j,z=z+k}):set_int("spread", 16)
|
||||
print ("[moontest] Added MR air node")
|
||||
if i*i+j*j+k*k <= 16 * 16 + 16 then
|
||||
--grab the location of the node in question
|
||||
local vi = area:index(x+i, y+j, z+k)
|
||||
--if it's vacuum, it won't be now!
|
||||
if data[vi] == c_vac then
|
||||
data[vi] = c_gair
|
||||
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
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue