Compare commits

..

No commits in common. "master" and "nalc-1.0" have entirely different histories.

5 changed files with 11 additions and 15 deletions

View File

@ -40,10 +40,9 @@ mymod.speed_monoid = player_monoids.make_monoid({
end,
fold = function(tab)
local res = 1
for _, speed in pairs(tab) do
for _, speed in pairs(tab) do
res = res * speed
end
return res
end
end,
identity = 1,
apply = function(speed, player)
@ -109,10 +108,9 @@ newmod.speed_boosts = player_monoids.make_monoid({
end,
fold = function(tab)
local res = 1
for _, speed in pairs(tab) do
for _, speed in pairs(tab) do
res = math.max(res, speed)
end
return res
end
end,
identity = 1,
apply = ???
@ -204,4 +202,4 @@ global state.
* The order that different effects get combined together is based on key order,
which may not be predictable. So you should try to make your monoids commutative
in addition to associative, or at least not care if the order of two changes
is swapped.
is swapped.

2
description.txt Normal file
View File

@ -0,0 +1,2 @@
player_monoids is a library for managing global player state, such as physics
overrides or player visual size.

View File

@ -1,5 +1 @@
name = player_monoids
description = """
A library for managing global player state,
such as physics overrides or player visual size.
"""
name=player_monoids

View File

@ -63,6 +63,7 @@ player_monoids.jump = monoid({
end,
})
-- Gravity monoid. Effect values are gravity multipliers.
player_monoids.gravity = monoid({
combine = mult,
@ -75,6 +76,7 @@ player_monoids.gravity = monoid({
end,
})
-- Fly ability monoid. The values are booleans, which are combined by or. A true
-- value indicates having the ability to fly.
player_monoids.fly = monoid({
@ -102,6 +104,7 @@ player_monoids.fly = monoid({
end,
})
-- Noclip ability monoid. Works the same as fly monoid.
player_monoids.noclip = monoid({
combine = function(p, q) return p or q end,

View File

@ -4,7 +4,6 @@ local speed = player_monoids.speed
minetest.register_privilege("monoid_master", {
description = "Allows testing of player monoids.",
give_to_singleplayer = false,
give_to_admin = true,
})
local function test(player)
@ -14,8 +13,6 @@ local function test(player)
minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
minetest.after(3, function()
local player = minetest.get_player_by_name(p_name)
if not player then return end
speed:del_change(player, ch_id)
minetest.chat_send_player(p_name, "Your speed is: " .. speed:value(player))
end)