diff --git a/commands.lua b/commands.lua new file mode 100644 index 0000000..e3da0d5 --- /dev/null +++ b/commands.lua @@ -0,0 +1,35 @@ +minetest.register_privilege("monoid_master", "Lets you apply effects to players") + +minetest.register_chatcommand("apply_effect", + { params = " ", + description = "Applies effect to player", + privs = { monoid_master = true }, + func = function(p_name, param) + local target, eff, dur = + param:match("^[^ ]+) +([^ ]+) +(.+)$") + if not target then + return false, "Target name required" + end + + if not eff then + return false, "Effect name required" + end + + if not dur then + return false, "Duration required" + end + + local duration = tonumber(dur) + + if not duration then + return false, "Duration must be a number" + end + + if duration <= 0 then + return false, "Duration must be positive" + end + + monoidal_effects.apply_effect(eff, math.ceil(duration), target) + return true + end, +})