Incorporate standard monoids to test and init

This commit is contained in:
raymoo 2016-01-26 20:37:02 -08:00
parent 09f5cda504
commit a32fb4e5ad
2 changed files with 7 additions and 28 deletions

View File

@ -747,6 +747,7 @@ minetest.register_on_shutdown(function()
save_effects(backup_path) save_effects(backup_path)
end) end)
dofile(mod_path .. "standard_monoids.lua")
local debug = minetest.setting_getbool("debug_effects") local debug = minetest.setting_getbool("debug_effects")

View File

@ -1,41 +1,19 @@
-- Speed monoid
monoidal_effects.register_monoid("monoidal_effects:speed",
{ combine = function(x, y) return x * y end,
fold = function(elems)
local res = 1
for k, v in pairs(elems) do
res = res * v
end
return res
end,
identity = 1,
apply = function(mult, player)
player:set_physics_override(
{ speed = mult
})
end,
on_change = function(m1, m2, player)
minetest.chat_send_all(m1.." boop "..m2)
end,
})
-- Static half speed -- Static half speed
monoidal_effects.register_type("monoidal_effects:half_speed", monoidal_effects.register_type("monoidal_effects:half_speed",
{ disp_name = "Half Speed", { disp_name = "Half Speed",
tags = {test = true}, tags = {test = true},
monoids = {["monoidal_effects:speed"] = true}, monoids = {speed = true},
cancel_on_death = true, cancel_on_death = true,
values = { ["monoidal_effects:speed"] = 0.5 }, values = {speed = 0.5},
}) })
-- 3x speed plus heavy gravity
monoidal_effects.register_type("monoidal_effects:three_speed", monoidal_effects.register_type("monoidal_effects:three_speed",
{ disp_name = "3x Speed", { disp_name = "3x Speed",
tags = {test = true}, tags = {test = true},
monoids = {["monoidal_effects:speed"] = true}, monoids = {speed = true, gravity = true},
cancel_on_death = true, cancel_on_death = true,
values = { ["monoidal_effects:speed"] = 3 }, values = {speed = 3, gravity = 10},
}) })
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
@ -46,7 +24,7 @@ minetest.register_on_joinplayer(function(player)
) )
monoidal_effects.apply_effect("monoidal_effects:three_speed", monoidal_effects.apply_effect("monoidal_effects:three_speed",
2, 8,
player:get_player_name() player:get_player_name()
) )
end) end)