From 0097cb17109f4c341b344f6d24805d435536bf58 Mon Sep 17 00:00:00 2001 From: wilkgr Date: Sat, 29 Jul 2017 14:00:02 +1000 Subject: [PATCH] v2.0: You can now specify groups of players. Use commas to separate players: e.g. /freeze you,me --- init.lua | 153 +++++++++++++++++++++++++++---------------------------- 1 file changed, 75 insertions(+), 78 deletions(-) diff --git a/init.lua b/init.lua index baa0138..c249cac 100644 --- a/init.lua +++ b/init.lua @@ -3,96 +3,100 @@ 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) - end - minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!") - player:set_physics_override({ - gravity = -0.1 - }) - end, + 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 + end, }) minetest.register_chatcommand("freeze", { params = "", 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) - end - minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!") - player:set_physics_override({ - jump = 0, - speed = 0 - }) - end, + 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 + end, }) minetest.register_chatcommand("jump",{ params = "", 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) - end - minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!") - player:set_physics_override({ - jump = 1000 - }) - end + func = function(name, param) + 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 = 1000}) + minetest.chat_send_player(name, "Gave sumperjump to " .. players[i]) + end +end, }) minetest.register_chatcommand("fast",{ params = "", 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) - end - minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!") - player:set_physics_override({ - speed = 10 - }) - end + func = function(name, param) + 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({speed = 10}) + minetest.chat_send_player(name, "Gave superspeed to " .. players[i]) + end +end, }) minetest.register_chatcommand("controls",{ params = "", 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) - end - minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!") - player:set_physics_override({ - speed = -1.0 - }) - end + func = function(name, param) + 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({speed = -1}) + minetest.chat_send_player(name, "Gave antispeed to " .. players[i]) + end +end, }) minetest.register_chatcommand("glide",{ params = "", 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) - end - minetest.chat_send_player(name, "Target locked...FIRE! Direct hit!") - player:set_physics_override({ - jump = 0.3, - gravity = 0.1 - }) - end + func = function(name, param) + 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.3, gravity = 0.1}) + minetest.chat_send_player(name, "Gave glidability to " .. players[i]) + end + end, }) @@ -100,22 +104,15 @@ minetest.register_chatcommand("reset",{ params = "", 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) - 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, + func = function(name, param) + 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 + end, })