From 723301dd12c1ac5da35a4df1a2cecee2777b9b44 Mon Sep 17 00:00:00 2001 From: -sniper- <47271658+JostP@users.noreply.github.com> Date: Fri, 12 Mar 2021 18:02:30 +0100 Subject: [PATCH] Sword marker: Decrease cooldowns, fix trivial bug (#826) * Improve sword markers * Fix timer * checks every 2 seconds * Edit string sent to chat * Clean up and increase sword special cooldown Co-authored-by: LoneWolfHT --- mods/ctf/ctf_classes/melee.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mods/ctf/ctf_classes/melee.lua b/mods/ctf/ctf_classes/melee.lua index 9302904..2b33700 100644 --- a/mods/ctf/ctf_classes/melee.lua +++ b/mods/ctf/ctf_classes/melee.lua @@ -29,12 +29,12 @@ end, true) local sword_special_timer = {} -local SWORD_SPECIAL_COOLDOWN = 40 +local SWORD_SPECIAL_COOLDOWN = 20 local function sword_special_timer_func(pname, timeleft) sword_special_timer[pname] = timeleft - if timeleft - 10 >= 0 then - minetest.after(10, sword_special_timer_func, pname, timeleft - 10) + if timeleft - 2 >= 0 then + minetest.after(2, sword_special_timer_func, pname, timeleft - 2) else sword_special_timer[pname] = nil end @@ -57,8 +57,8 @@ minetest.register_tool("ctf_classes:sword_bronze", { local pname = placer:get_player_name() if not pointed_thing then return end - if sword_special_timer[pname] then - minetest.chat_send_player(pname, "You can't place a marker yet (>"..sword_special_timer[pname].."s left)") + if sword_special_timer[pname] and placer:get_player_control().sneak then + minetest.chat_send_player(pname, "You have to wait "..sword_special_timer[pname].."s to place marker again") if pointed_thing.type == "node" then return minetest.item_place(itemstack, placer, pointed_thing) @@ -102,8 +102,8 @@ minetest.register_tool("ctf_classes:sword_bronze", { -- Check if player is sneaking before placing marker if not placer:get_player_control().sneak then return end - sword_special_timer[pname] = 20 - sword_special_timer_func(pname, 20) + sword_special_timer[pname] = 4 + sword_special_timer_func(pname, 4) minetest.registered_chatcommands["m"].func(pname, "placed with sword") end,