v2.0: You can now specify groups of players. Use commas to separate players: e.g. /freeze you,me

This commit is contained in:
wilkgr 2017-07-29 14:00:02 +10:00
parent ed1e738665
commit 0097cb1710

115
init.lua
View File

@ -3,14 +3,15 @@ minetest.register_chatcommand("antigravity", {
description = "Gives that person antigravity",
privs = {server=true},
func = function(name, param)
local player = minetest.get_player_by_name(param)
if player == nil then
player = minetest.get_player_by_name(name)
if param == nil then
param = name
end
players = string.split(param,",");
for i=1,#players do
local currplayer = minetest.get_player_by_name(players[i]);
currplayer:set_physics_override({gravity = -0.1})
minetest.chat_send_player(name, "Gave antigravity to " .. players[i])
end
minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!")
player:set_physics_override({
gravity = -0.1
})
end,
})
minetest.register_chatcommand("freeze", {
@ -18,15 +19,15 @@ minetest.register_chatcommand("freeze", {
description = "Sets speed+jump to 0. Can't move unless teleported or blocks removed under them",
privs = {server=true},
func = function(name, param)
local player = minetest.get_player_by_name(param)
if player == nil then
player = minetest.get_player_by_name(name)
if param == nil then
param = name
end
players = string.split(param,",");
for i=1,#players do
local currplayer = minetest.get_player_by_name(players[i]);
currplayer:set_physics_override({jump = 0, speed = 0})
minetest.chat_send_player(name, "Froze " .. players[i])
end
minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!")
player:set_physics_override({
jump = 0,
speed = 0
})
end,
})
@ -35,15 +36,16 @@ minetest.register_chatcommand("jump",{
description = "Gives that person huge jump boost, usually killing them.",
privs = {server=true},
func = function(name, param)
local player = minetest.get_player_by_name(param)
if player == nil then
player = minetest.get_player_by_name(name)
if param == nil then
param = name
end
minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!")
player:set_physics_override({
jump = 1000
})
players = string.split(param,",");
for i=1,#players do
local currplayer = minetest.get_player_by_name(players[i]);
currplayer:set_physics_override({jump = 1000})
minetest.chat_send_player(name, "Gave sumperjump to " .. players[i])
end
end,
})
minetest.register_chatcommand("fast",{
@ -51,15 +53,16 @@ minetest.register_chatcommand("fast",{
description = "Gives that person a lot of speed",
privs = {server=true},
func = function(name, param)
local player = minetest.get_player_by_name(param)
if player == nil then
player = minetest.get_player_by_name(name)
if param == nil then
param = name
end
minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!")
player:set_physics_override({
speed = 10
})
players = string.split(param,",");
for i=1,#players do
local currplayer = minetest.get_player_by_name(players[i]);
currplayer:set_physics_override({speed = 10})
minetest.chat_send_player(name, "Gave superspeed to " .. players[i])
end
end,
})
minetest.register_chatcommand("controls",{
@ -67,15 +70,16 @@ minetest.register_chatcommand("controls",{
description = "Gives that person very quirky controls, resulting in a literally uncontrollable character. Use with caution!",
privs = {server=true},
func = function(name, param)
local player = minetest.get_player_by_name(param)
if player == nil then
player = minetest.get_player_by_name(name)
if param == nil then
param = name
end
minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!")
player:set_physics_override({
speed = -1.0
})
players = string.split(param,",");
for i=1,#players do
local currplayer = minetest.get_player_by_name(players[i]);
currplayer:set_physics_override({speed = -1})
minetest.chat_send_player(name, "Gave antispeed to " .. players[i])
end
end,
})
minetest.register_chatcommand("glide",{
@ -83,16 +87,16 @@ minetest.register_chatcommand("glide",{
description = "Anti-fall damage. Slows your descent.",
privs = {server=true},
func = function(name, param)
local player = minetest.get_player_by_name(param)
if player == nil then
player = minetest.get_player_by_name(name)
if param == nil then
param = name
end
minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!")
player:set_physics_override({
jump = 0.3,
gravity = 0.1
})
players = string.split(param,",");
for i=1,#players do
local currplayer = minetest.get_player_by_name(players[i]);
currplayer:set_physics_override({jump = 0.3, gravity = 0.1})
minetest.chat_send_player(name, "Gave glidability to " .. players[i])
end
end,
})
@ -101,21 +105,14 @@ minetest.register_chatcommand("reset",{
description = "Resets gravity, eye offset, visual size and whether they are invisible",
privs = {server=true},
func = function(name, param)
local player = minetest.get_player_by_name(param)
if player == nil then
player = minetest.get_player_by_name(name)
if param == nil then
param = name
end
players = string.split(param,",");
for i=1,#players do
local currplayer = minetest.get_player_by_name(players[i]);
currplayer:set_physics_override({jump = 1, gravity = 1, speed = 1})
minetest.chat_send_player(name, "Reset physics of " .. players[i])
end
player:set_eye_offset({x=0,y=0,z=0},{x=0,y=0,z=0})
player:set_properties({
visual_size = {x=1, y=1, z=1}
})
minetest.chat_send_player(param, "Your gravity has been reset! FREEDOM!")
player:set_physics_override({
speed = 1.0,
gravity = 1.0,
jump = 1.0
})
end,
})