mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 23:33:53 +01:00
Extended liquid tests
This commit is contained in:
parent
3631b1c4ca
commit
8ad7c3de7c
31
test.lua
31
test.lua
@ -5,7 +5,12 @@ 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 = {
|
||||||
|
liquid_dir = false,
|
||||||
|
liquid_raycast = false
|
||||||
|
}
|
||||||
|
if tests.liquid_dir then
|
||||||
|
minetest.register_abm{
|
||||||
label = "get_liquid_corner_levels & get_liquid_direction test",
|
label = "get_liquid_corner_levels & get_liquid_direction test",
|
||||||
nodenames = {"default:water_flowing"},
|
nodenames = {"default:water_flowing"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
@ -14,7 +19,7 @@ minetest.register_abm{
|
|||||||
assert(type(node) == "table")
|
assert(type(node) == "table")
|
||||||
for _, corner_level in pairs(modlib.minetest.get_liquid_corner_levels(pos, node)) do
|
for _, corner_level in pairs(modlib.minetest.get_liquid_corner_levels(pos, node)) do
|
||||||
minetest.add_particle{
|
minetest.add_particle{
|
||||||
pos = vector.subtract(vector.add(pos, corner_level), 0.5),
|
pos = vector.add(pos, corner_level),
|
||||||
size = 2,
|
size = 2,
|
||||||
texture = "logo.png"
|
texture = "logo.png"
|
||||||
}
|
}
|
||||||
@ -30,4 +35,24 @@ minetest.register_abm{
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end
|
||||||
|
if tests.liquid_raycast then
|
||||||
|
minetest.register_globalstep(function()
|
||||||
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
|
local eye_pos = vector.offset(player:get_pos(), 0, player:get_properties().eye_height, 0)
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user