1 ----- EXAMPLE EFFECT TYPES -----
3 -- Makes the user faster
4 playereffects
.register_effect_type("high_speed", "High speed", nil, {"speed"},
6 player
:set_physics_override(4,nil,nil)
10 local player
= minetest
.get_player_by_name(effect
.playername
)
11 player
:set_physics_override(1,nil,nil)
15 -- Slows the user down
16 playereffects
.register_effect_type("low_speed", "Low speed", nil, {"speed"},
18 player
:set_physics_override(0.25,nil,nil)
22 local player
= minetest
.get_player_by_name(effect
.playername
)
23 player
:set_physics_override(1,nil,nil)
27 -- Increases the jump height
28 playereffects
.register_effect_type("highjump", "Greater jump height", "playereffects_example_highjump.png", {"jump"},
30 player
:set_physics_override(nil,2,nil)
33 local player
= minetest
.get_player_by_name(effect
.playername
)
34 player
:set_physics_override(nil,1,nil)
38 -- Adds the “fly” privilege
39 playereffects
.register_effect_type("fly", "Fly mode available", "playereffects_example_fly.png", {"fly"},
41 local playername
= player
:get_player_name()
42 local privs
= minetest
.get_player_privs(playername
)
44 minetest
.set_player_privs(playername
, privs
)
47 local privs
= minetest
.get_player_privs(effect
.playername
)
49 minetest
.set_player_privs(effect
.playername
, privs
)
53 -- Dummy effect for the stree test
54 playereffects
.register_effect_type("stress", "Stress Test Effect", nil, {},
62 ------ Chat commands for the example effects ------
64 minetest
.register_chatcommand("fast", {
66 description
= "Makes you fast for a short time.",
68 func
= function(name
, param
)
69 playereffects
.apply_effect_type("high_speed", 10, minetest
.get_player_by_name(name
))
72 minetest
.register_chatcommand("slow", {
74 description
= "Makes you slow for a long time.",
76 func
= function(name
, param
)
77 playereffects
.apply_effect_type("low_speed", 120, minetest
.get_player_by_name(name
))
80 minetest
.register_chatcommand("highjump", {
82 description
= "Makes you jump higher for a short time.",
84 func
= function(name
, param
)
85 playereffects
.apply_effect_type("highjump", 20, minetest
.get_player_by_name(name
))
89 minetest
.register_chatcommand("fly", {
91 description
= "Grants you the fly privilege for a short time.",
93 func
= function(name
, param
)
94 playereffects
.apply_effect_type("fly", 20, minetest
.get_player_by_name(name
))
98 --[[ The stress test applies a shitload of effects at once.
99 This is used to test the performance of this mod at very large effect numbers. ]]
100 minetest
.register_chatcommand("stresstest", {
101 params
= "[<effects>]",
102 descriptions
= "Start the stress test for Player Effects with <effects> effects.",
103 privs
= {server
=true},
104 func
= function(name
, param
)
105 local player
= minetest
.get_player_by_name(name
)
107 if(type(param
)=="string") then
108 if(type(tonumber(param
)) == "number") then
109 max = tonumber(param
)
110 if(max > 1000) then max = 1000 end
113 minetest
.debug("[playereffects] Stress test started for "..name
.." with "..max.." effects.")
115 playereffects
.apply_effect_type("stress", 10, player
)