From a32fb4e5ad2520c99083be94a857e35dee893bde Mon Sep 17 00:00:00 2001 From: raymoo Date: Tue, 26 Jan 2016 20:37:02 -0800 Subject: [PATCH] Incorporate standard monoids to test and init --- init.lua | 1 + test_effects.lua | 34 ++++++---------------------------- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/init.lua b/init.lua index b930ddf..304c6df 100644 --- a/init.lua +++ b/init.lua @@ -747,6 +747,7 @@ minetest.register_on_shutdown(function() save_effects(backup_path) end) +dofile(mod_path .. "standard_monoids.lua") local debug = minetest.setting_getbool("debug_effects") diff --git a/test_effects.lua b/test_effects.lua index 10ecc96..1308b53 100644 --- a/test_effects.lua +++ b/test_effects.lua @@ -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 monoidal_effects.register_type("monoidal_effects:half_speed", { disp_name = "Half Speed", tags = {test = true}, - monoids = {["monoidal_effects:speed"] = true}, + monoids = {speed = 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", { disp_name = "3x Speed", tags = {test = true}, - monoids = {["monoidal_effects:speed"] = true}, + monoids = {speed = true, gravity = true}, cancel_on_death = true, - values = { ["monoidal_effects:speed"] = 3 }, + values = {speed = 3, gravity = 10}, }) minetest.register_on_joinplayer(function(player) @@ -46,7 +24,7 @@ minetest.register_on_joinplayer(function(player) ) monoidal_effects.apply_effect("monoidal_effects:three_speed", - 2, + 8, player:get_player_name() ) end)