Branching system (#10)

This commit enhances the player_monoids library by adding branching support and an improved testing system to make sure it works, as proposed in #9 . These changes enable isolated player state management and improve library reliability. This PR focuses on implementing the branching proposal and adding automated tests.
This commit is contained in:
Gio
2025-05-17 18:10:30 +02:00
committed by GitHub
parent 8d6f1ade93
commit ee81c59f2c
5 changed files with 1164 additions and 288 deletions

View File

@ -98,7 +98,6 @@ player_monoids.fly = monoid({
end
minetest.set_player_privs(p_name, privs)
end,
})
@ -124,30 +123,29 @@ player_monoids.noclip = monoid({
end
minetest.set_player_privs(p_name, privs)
end,
})
local def_col_scale = { x=0.3, y=1, z=0.3 }
local def_col_scale = {x = 0.3, y = 1, z = 0.3}
-- Collisionbox scaling factor. Values are a vector of x, y, z multipliers.
player_monoids.collisionbox = monoid({
combine = v_mult,
fold = v_mult_fold({x=1, y=1, z=1}),
identity = {x=1, y=1, z=1},
fold = v_mult_fold({x = 1, y = 1, z = 1}),
identity = {x = 1, y = 1, z = 1},
apply = function(multiplier, player)
local v = vector.multiply(def_col_scale, multiplier)
player:set_properties({
collisionbox = { -v.x, -v.y, -v.z, v.z, v.y, v.z }
collisionbox = {-v.x, -v.y, -v.z, v.z, v.y, v.z}
})
end,
})
player_monoids.visual_size = monoid({
combine = v_mult,
fold = v_mult_fold({x=1, y=1}),
identity = {x=1, y=1},
fold = v_mult_fold({x = 1, y = 1}),
identity = {x = 1, y = 1},
apply = function(multiplier, player)
player:set_properties({
visual_size = multiplier