Add /setbreath
parent
e89f9b8f1b
commit
550a461bcb
1
README
1
README
|
@ -21,6 +21,7 @@ The privileges are created for the health, physics and hotbar-related commands a
|
|||
=== “heal” privilege required ===
|
||||
/sethealth <hearts> Sets your health to <hearts> hearts.
|
||||
/sethp <hp> Sets your health to <hp> HP (=hearts/2).
|
||||
/setbreath <breath> Sets your health to <breath> breath points.
|
||||
|
||||
The “sethp” command rounds <hp>.
|
||||
The “sethealth” command rounds <hearts> to the nearest half, i.e:
|
||||
|
|
28
init.lua
28
init.lua
|
@ -1,5 +1,5 @@
|
|||
--[[ privileges ]]
|
||||
minetest.register_privilege("heal",{description = "Allows player to set own health with /sethp and /sethealth.", give_to_singleplayer = false})
|
||||
minetest.register_privilege("heal",{description = "Allows player to set own health and breath with /sethp, /sethealth and /setbreath.", give_to_singleplayer = false})
|
||||
minetest.register_privilege("physics",{description = "Allows player to set own gravity, jump height and movement speed with /setgravity, /setjump and /setspeed, respectively.", give_to_singleplayer = false})
|
||||
minetest.register_privilege("hotbar",{description = "Allows player to set the number of slots of the hotbar with /sethotbarsize.", give_to_singleplayer = false})
|
||||
|
||||
|
@ -99,6 +99,32 @@ minetest.register_chatcommand("sethealth", {
|
|||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("setbreath", {
|
||||
params = "<breath>",
|
||||
description = "Sets your breath to <breath> breath points.",
|
||||
privs = {heal=true},
|
||||
func = function(name, breath)
|
||||
if(minetest.setting_getbool("enable_damage")==true) then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
if breath == "" then
|
||||
minetest.chat_send_player(name, "You did not specify the parameter.")
|
||||
return
|
||||
end
|
||||
if type(tonumber(breath)) ~= "number" then
|
||||
minetest.chat_send_player(name, "This is not a number.")
|
||||
return
|
||||
end
|
||||
local bp = tonumber(breath)
|
||||
player:set_breath(bp)
|
||||
else
|
||||
minetest.chat_send_player(name, "Damage is disabled on this server. This command does not work when damage is disabled.")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_chatcommand("killme", {
|
||||
params = "",
|
||||
|
|
Loading…
Reference in New Issue