Initial commit: Version 1.2
This commit is contained in:
commit
6fe53ba3c5
57
README
Normal file
57
README
Normal file
@ -0,0 +1,57 @@
|
||||
= Player tools 1.2 [playertools] =
|
||||
This mod adds some player-related server commands and privileges to Minetest.
|
||||
Most commands are little helper tools, useful for modders and for messing around,
|
||||
but they aren’t really suitable for serious gameplay. Some commands are informational.
|
||||
The commands allow players to change their health, clear their inventory, set their player physics,
|
||||
and other stuff.
|
||||
The privileges are created for the health, physics and hotbar-related commands and are named “heal”,
|
||||
“physics” and “hotbar”, respectively.
|
||||
|
||||
== List of commands ==
|
||||
=== no privileges required ===
|
||||
/whoami Shows your name in a chat message.
|
||||
/ip Shows your IP address in a chat message.
|
||||
|
||||
/pulverizeall Destroys all items in your player inventory and crafting grid.
|
||||
/killme Kills yourself.
|
||||
|
||||
=== “hotbar” privilege required ===
|
||||
/sethotbarsize <1...23> Sets the number of slots in your hotbar (1-23).
|
||||
|
||||
=== “heal” privilege required ===
|
||||
/sethealth <hearts> Sets your health to <hearts> hearts.
|
||||
/sethp <hp> Sets your health to <hp> HP (=hearts/2).
|
||||
|
||||
The “sethp” command rounds <hp>.
|
||||
The “sethealth” command rounds <hearts> to the nearest half, i.e:
|
||||
2.5 → 2.5
|
||||
2.6 → 2.5
|
||||
2.7 → 2.5
|
||||
2.75 → 3
|
||||
2.8 → 3
|
||||
|
||||
=== “physics” privilege required ===
|
||||
/setspeed [<speed>] Sets your movement speed to <speed> (default: 1).
|
||||
/setgravity [<gravity>] Sets your gravity to <gravity> (default: 1).
|
||||
/setjump [<jump height>] Sets your jump height to <jump height> (default: 1).
|
||||
|
||||
These commands directly edit the player’s physics parameters.
|
||||
|
||||
|
||||
== Installation ==
|
||||
You can either install the player tools as an ordinary mod or as a builtin, but please don’t do both.
|
||||
Installing it as a mod is very easy, but you have to activate the mod explicitly for each map.
|
||||
Installing it as builtin is easy and the player tools are automatically available for every
|
||||
server you start.
|
||||
|
||||
To install it as a mod, just drop this folder into the mods/ folder of your Minetest data folder.
|
||||
|
||||
To install it as builtin do this:
|
||||
(For version 0.4.9)
|
||||
Rename the file “init.lua” to “mod_playertools.lua” and move it to <your Minetest installation folder>/builtin/.
|
||||
Then edit the file <your Minetest installation folder>/builtin/builtin.lua. Add the following line of text at the
|
||||
end of the file:
|
||||
|
||||
dofile(modpath.."/mod_playertools.lua")
|
||||
|
||||
Save the file; you’re finished! The next time you start a server the player tools are available.
|
0
depends.txt
Normal file
0
depends.txt
Normal file
1
description.txt
Normal file
1
description.txt
Normal file
@ -0,0 +1 @@
|
||||
Some useful server commands for players.
|
198
init.lua
Normal file
198
init.lua
Normal file
@ -0,0 +1,198 @@
|
||||
--[[ privileges ]]
|
||||
minetest.register_privilege("heal",{description = "Allows player to set own health with /sethp and /sethealth.", 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})
|
||||
|
||||
--[[ informational commands ]]
|
||||
minetest.register_chatcommand("whoami", {
|
||||
params = "",
|
||||
description = "Shows your name.",
|
||||
privs = {},
|
||||
func = function(name)
|
||||
minetest.chat_send_player(name, "Your name is \""..name.."\".")
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("ip", {
|
||||
params = "",
|
||||
description = "Shows your IP address.",
|
||||
privs = {},
|
||||
func = function(name)
|
||||
minetest.chat_send_player(name, "Your IP address is \""..minetest.get_player_ip(name).."\".")
|
||||
end
|
||||
})
|
||||
|
||||
--[[ HUD commands ]]
|
||||
minetest.register_chatcommand("sethotbarsize", {
|
||||
params = "<1...23>",
|
||||
description = "Sets the size of your hotbar to the provided number of slots. The number must be between 1 and 23.",
|
||||
privs = {hotbar=true},
|
||||
func = function(name, slots)
|
||||
if slots == "" then
|
||||
minetest.chat_send_player(name, "You did not specify the parameter.")
|
||||
return
|
||||
end
|
||||
if type(tonumber(slots)) ~= "number" then
|
||||
minetest.chat_send_player(name, "This is not a number.")
|
||||
return
|
||||
end
|
||||
if tonumber(slots) < 1 or tonumber(slots) > 23 then
|
||||
minetest.chat_send_player(name, "Number of slots out of bounds. The number of slots must be between 1 and 23.")
|
||||
return
|
||||
end
|
||||
local player = minetest.get_player_by_name(name)
|
||||
player:hud_set_hotbar_itemcount(tonumber(slots))
|
||||
end,
|
||||
})
|
||||
|
||||
--[[ health commands ]]
|
||||
minetest.register_chatcommand("sethp", {
|
||||
params = "<hp>",
|
||||
description = "Sets your health to <hp> HP (=hearts/2).",
|
||||
privs = {heal=true},
|
||||
func = function(name, hp)
|
||||
if(minetest.setting_getbool("enable_damage")==true) then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
if hp == "" then
|
||||
minetest.chat_send_player(name, "You did not specify the parameter.")
|
||||
return
|
||||
end
|
||||
if type(tonumber(hp)) ~= "number" then
|
||||
minetest.chat_send_player(name, "This is not a number.")
|
||||
return
|
||||
end
|
||||
hp = math.floor(hp+0.5) -- round the number
|
||||
player:set_hp(tonumber(hp))
|
||||
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("sethealth", {
|
||||
params = "<hearts>",
|
||||
description = "Sets your health to <hearts> hearts.",
|
||||
privs = {heal=true},
|
||||
func = function(name, hearts)
|
||||
if(minetest.setting_getbool("enable_damage")==true) then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
if hearts == "" then
|
||||
minetest.chat_send_player(name, "You did not specify the parameter.")
|
||||
return
|
||||
end
|
||||
if type(tonumber(hearts)) ~= "number" then
|
||||
minetest.chat_send_player(name, "This is not a number.")
|
||||
return
|
||||
end
|
||||
local hp = tonumber(hearts) * 2
|
||||
hp = math.floor(hp+0.5) -- round the number
|
||||
player:set_hp(hp)
|
||||
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 = "",
|
||||
description = "Kills yourself.",
|
||||
func = function(name, param)
|
||||
if(minetest.setting_getbool("enable_damage")==true) then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
player:set_hp(0)
|
||||
else
|
||||
minetest.chat_send_player(name, "Damage is disabled on this server. This command does not work when damage is disabled.")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--[[ Player physics commands ]]
|
||||
|
||||
-- speed
|
||||
minetest.register_chatcommand("setspeed", {
|
||||
params = "[<speed>]",
|
||||
description = "Sets your movement speed to <speed> (default: 1).",
|
||||
privs={physics=true},
|
||||
func = function(name, speed)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
if speed == "" then
|
||||
speed=1
|
||||
end
|
||||
if type(tonumber(speed)) ~= "number" then
|
||||
minetest.chat_send_player(name, "This is not a number.")
|
||||
return
|
||||
end
|
||||
|
||||
player:set_physics_override(tonumber(speed), nil, nil)
|
||||
end,
|
||||
})
|
||||
|
||||
-- gravity
|
||||
minetest.register_chatcommand("setgravity", {
|
||||
params = "[<gravity>]",
|
||||
description = "Sets your gravity to [<gravity>] (default: 1).",
|
||||
privs={physics=true},
|
||||
func = function(name, gravity)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
if gravity == "" then
|
||||
gravity=1
|
||||
end
|
||||
if type(tonumber(gravity)) ~= "number" then
|
||||
minetest.chat_send_player(name, "This is not a number.")
|
||||
return
|
||||
end
|
||||
player:set_physics_override(nil, tonumber(gravity), nil)
|
||||
end,
|
||||
})
|
||||
|
||||
-- jump height
|
||||
minetest.register_chatcommand("setjump", {
|
||||
params = "[<jump height>]",
|
||||
description = "Sets your jump height to [<jump height>] (default: 1).",
|
||||
privs = {physics=true},
|
||||
func = function(name, jump_height)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
if jump_height == "" then
|
||||
jump_height=1
|
||||
end
|
||||
if type(tonumber(jump_height)) ~= "number" then
|
||||
minetest.chat_send_player(name, "This is not a number.")
|
||||
return
|
||||
end
|
||||
player:set_physics_override(nil, nil, jump_height)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("pulverizeall", {
|
||||
params = "",
|
||||
description = "Destroys all items in your player inventory and crafting grid.",
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local inv = player:get_inventory()
|
||||
inv:set_list("main", {})
|
||||
inv:set_list("craft", {})
|
||||
end,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user