Extended liquid tests

This commit is contained in:
Lars Mueller 2020-12-21 20:26:06 +01:00
parent 3631b1c4ca
commit 8ad7c3de7c

@ -5,29 +5,54 @@ local t2 = modlib.table.deepcopy(t)
assert(t2[t2] == t2) assert(t2[t2] == t2)
assert(modlib.table.equals_noncircular({[{}]={}}, {[{}]={}})) assert(modlib.table.equals_noncircular({[{}]={}}, {[{}]={}}))
minetest.register_abm{ local tests = {
label = "get_liquid_corner_levels & get_liquid_direction test", liquid_dir = false,
nodenames = {"default:water_flowing"}, liquid_raycast = false
interval = 1, }
chance = 1, if tests.liquid_dir then
action = function(pos, node) minetest.register_abm{
assert(type(node) == "table") label = "get_liquid_corner_levels & get_liquid_direction test",
for _, corner_level in pairs(modlib.minetest.get_liquid_corner_levels(pos, node)) do nodenames = {"default:water_flowing"},
minetest.add_particle{ interval = 1,
pos = vector.subtract(vector.add(pos, corner_level), 0.5), chance = 1,
size = 2, action = function(pos, node)
texture = "logo.png" assert(type(node) == "table")
} for _, corner_level in pairs(modlib.minetest.get_liquid_corner_levels(pos, node)) do
minetest.add_particle{
pos = vector.add(pos, corner_level),
size = 2,
texture = "logo.png"
}
end
local direction = modlib.minetest.get_liquid_flow_direction(pos, node)
local start_pos = pos
start_pos.y = start_pos.y + 1
for i = 0, 20 do
minetest.add_particle{
pos = vector.add(start_pos, vector.multiply(direction, i/20)),
size = i/10,
texture = "logo.png"
}
end
end end
local direction = modlib.minetest.get_liquid_flow_direction(pos, node) }
local start_pos = pos
start_pos.y = start_pos.y + 1 end
for i = 0, 20 do if tests.liquid_raycast then
minetest.add_particle{ minetest.register_globalstep(function()
pos = vector.add(start_pos, vector.multiply(direction, i/20)), for _, player in pairs(minetest.get_connected_players()) do
size = i/10, local eye_pos = vector.offset(player:get_pos(), 0, player:get_properties().eye_height, 0)
texture = "logo.png" local raycast = modlib.minetest.raycast(eye_pos, vector.add(eye_pos, vector.multiply(player:get_look_dir(), 3)), false, true)
} for pointed_thing in raycast do
if pointed_thing.type == "node" and minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].liquidtype == "flowing" then
minetest.add_particle{
pos = vector.add(pointed_thing.intersection_point, vector.multiply(pointed_thing.intersection_normal, 0.1)),
size = 0.5,
texture = "object_marker_red.png",
expirationtime = 3
}
end
end
end end
end end)
} end