Add new example effect: grant fly privilege

This commit is contained in:
Wuzzy 2014-07-06 18:30:32 +02:00
parent e6d96f119a
commit c62e857564
1 changed files with 23 additions and 1 deletions

View File

@ -63,7 +63,7 @@ function playereffects.apply_effect_type(effect_type_id, duration, player)
end
if(smallest_hudpos == nil) then
smallest_hudpos = hudpos
elseif(hudids[h] < smallest_hudpos) then
elseif(hudpos < smallest_hudpos) then
smallest_hudpos = hudpos
end
end
@ -280,6 +280,19 @@ playereffects.register_effect_type("highjump", "greater jump height", {"jump"},
player:set_physics_override(nil,1,nil)
end
)
playereffects.register_effect_type("fly", "fly mode available", {"fly"},
function(player)
local playername = player:get_player_name()
local privs = minetest.get_player_privs(playername)
privs.fly = true
minetest.set_player_privs(playername, privs)
end,
function(effect)
local privs = minetest.get_player_privs(effect.playername)
privs.fly = nil
minetest.set_player_privs(effect.playername, privs)
end
)
minetest.register_chatcommand("fast", {
@ -306,3 +319,12 @@ minetest.register_chatcommand("highjump", {
playereffects.apply_effect_type("highjump", 20, minetest.get_player_by_name(name))
end,
})
minetest.register_chatcommand("fly", {
params = "",
description = "Grants you the fly privilege for a short time.",
privs = {},
func = function(name, param)
playereffects.apply_effect_type("fly", 20, minetest.get_player_by_name(name))
end,
})