From 6f0a34c07b134e3ee8622bd1ac15fda103b3a3c1 Mon Sep 17 00:00:00 2001 From: debiankaios Date: Sat, 8 Oct 2022 22:04:47 +0200 Subject: [PATCH] change now player_speed and player_jump for tagged players too. Closes #4 --- api.lua | 10 ++++++++++ init.lua | 16 ++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/api.lua b/api.lua index d471a9b..67069b9 100644 --- a/api.lua +++ b/api.lua @@ -36,16 +36,26 @@ end -- called when tagged function tnttag.tagplayer(p_name, arena) + local player = minetest.get_player_by_name(p_name) arena.players[p_name].tagged = true tnttag.add_tager(minetest.get_player_by_name(p_name)) tnttag.add_tnthead(p_name) + player:set_physics_override({ + speed = tnttag.player_speed_tagged, + jump = tnttag.player_jump_tagged, + }) end -- called when a player tags another player function tnttag.untagplayer(p_name, arena) + local player = minetest.get_player_by_name(p_name) arena.players[p_name].tagged = false tnttag.remove_tager(minetest.get_player_by_name(p_name)) tnttag.remove_tnthead(p_name) + player:set_physics_override({ + speed = tnttag.player_speed, + jump = tnttag.player_jump, + }) end -- get the get tagstatus diff --git a/init.lua b/init.lua index cd4333b..06b156f 100644 --- a/init.lua +++ b/init.lua @@ -3,14 +3,10 @@ local S = minetest.get_translator("tnttag") tnttag = {} tnttag.saved_huds = {} -local player_speed = minetest.settings:get("tnttag.player_speed") or 3 -local player_jump = minetest.settings:get("tnttag.player_jump") or 1.2 -local player_speed_tagged = minetest.settings:get("tnttag.player_speed_tagged") or 3 -local player_jump_tagged = minetest.settings:get("tnttag.player_jump_tagged") or 1.2 - -minetest.register_on_joinplayer(function(player) - print(player_speed) -end) +tnttag.player_speed = minetest.settings:get("tnttag.player_speed") or 3 +tnttag.player_jump = minetest.settings:get("tnttag.player_jump") or 1.2 +tnttag.player_speed_tagged = minetest.settings:get("tnttag.player_speed_tagged") or 3 +tnttag.player_jump_tagged = minetest.settings:get("tnttag.player_jump_tagged") or 1.2 arena_lib.register_minigame("tnttag", { prefix = "[tnttag] ", @@ -35,8 +31,8 @@ arena_lib.register_minigame("tnttag", { tnt_if_tagged, }, in_game_physics = { - speed = player_speed, - jump = player_jump, + speed = tnttag.player_speed, + jump = tnttag.player_jump, }, hotbar = { slots = 1,