vacuum override methods
This commit is contained in:
parent
ffd8f92cde
commit
76f2cd974a
16
common.lua
16
common.lua
@ -2,11 +2,17 @@
|
||||
|
||||
vacuum.air_bottle_image = "vessels_steel_bottle.png^[colorize:#0000FFAA"
|
||||
|
||||
-- returns true, if in space (with safety margin for abm)
|
||||
-- space pos checker
|
||||
vacuum.is_pos_in_space = function(pos)
|
||||
return pos.y > vacuum.space_height + 40
|
||||
return pos.y > vacuum.space_height
|
||||
end
|
||||
|
||||
vacuum.is_pos_on_earth = function(pos)
|
||||
return pos.y < vacuum.space_height - 40
|
||||
end
|
||||
-- (cheaper) space check, gets called more often than `is_pos_in_space`
|
||||
vacuum.no_vacuum_abm = function(pos)
|
||||
return pos.y > vacuum.space_height - 40 and pos.y < vacuum.space_height + 40
|
||||
end
|
||||
|
||||
-- checks if this mapblock is in space when generated
|
||||
vacuum.is_mapgen_block_in_space = function(minp, maxp)
|
||||
return minp.y > vacuum.space_height
|
||||
end
|
||||
|
@ -5,7 +5,7 @@ local c_air = minetest.get_content_id("air")
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
|
||||
if minp.y < vacuum.space_height then
|
||||
if not vacuum.is_mapgen_block_in_space(minp, maxp) then
|
||||
return
|
||||
end
|
||||
|
||||
|
14
physics.lua
14
physics.lua
@ -50,7 +50,7 @@ end
|
||||
|
||||
-- vacuum/air propagation
|
||||
minetest.register_abm({
|
||||
label = "space vacuum",
|
||||
label = "space vacuum",
|
||||
nodenames = {"air"},
|
||||
neighbors = {"vacuum:vacuum"},
|
||||
interval = 1,
|
||||
@ -59,14 +59,18 @@ minetest.register_abm({
|
||||
|
||||
if metric_space_vacuum_abm ~= nil then metric_space_vacuum_abm.inc() end
|
||||
|
||||
if vacuum.is_pos_on_earth(pos) or near_powered_airpump(pos) then
|
||||
if vacuum.no_vacuum_abm(pos) then
|
||||
return
|
||||
end
|
||||
|
||||
if not vacuum.is_pos_in_space(pos) or near_powered_airpump(pos) then
|
||||
-- on earth or near a powered airpump
|
||||
local node = minetest.find_node_near(pos, 1, {"vacuum:vacuum"})
|
||||
|
||||
if node ~= nil then
|
||||
minetest.set_node(node, {name = "air"})
|
||||
end
|
||||
elseif vacuum.is_pos_in_space(pos) then
|
||||
else
|
||||
-- in space, evacuate air
|
||||
minetest.set_node(pos, {name = "vacuum:vacuum"})
|
||||
end
|
||||
@ -183,10 +187,10 @@ minetest.register_abm({
|
||||
action = throttle(250, function(pos)
|
||||
if metric_space_vacuum_leak_abm ~= nil then metric_space_vacuum_leak_abm.inc() end
|
||||
|
||||
if vacuum.is_pos_on_earth(pos) or near_powered_airpump(pos) then
|
||||
if not vacuum.is_pos_in_space(pos) or near_powered_airpump(pos) then
|
||||
-- on earth: TODO: replace vacuum with air
|
||||
return
|
||||
elseif vacuum.is_pos_in_space(pos) then
|
||||
else
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
if node.name == "pipeworks:entry_panel_empty" or node.name == "pipeworks:entry_panel_loaded" then
|
||||
|
@ -13,6 +13,7 @@ minetest.register_node("vacuum:vacuum", {
|
||||
alpha = 0.1,
|
||||
groups = {not_in_creative_inventory=1, not_blocking_trains=1, cools_lava=1},
|
||||
paramtype = "light",
|
||||
-- light_source = minetest.LIGHT_MAX, TOOD: test
|
||||
drop = {},
|
||||
sunlight_propagates = true
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user