Skip to content

Commit

Permalink
Notify player when combat mode timer increases while inside blocks (#…
Browse files Browse the repository at this point in the history
…1246)

* Add suffocation message

* Dealing with luacheck

* Only a 3-year-old would make this kind of mistake
  • Loading branch information
a-blob authored Nov 25, 2023
1 parent d534180 commit 5dfebc6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mods/ctf/ctf_combat/ctf_combat_mode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ local function update(player)
return
end

local hud_message = "You are in combat [%ds left]"
hud_message = hud_message:format(combat.time)
local hud_message = "You are in combat [%ds left] \n%s"
hud_message = hud_message:format(combat.time, combat.suffocation_message)

if hud:exists(player, "combat_indicator") then
hud:change(player, "combat_indicator", {
Expand All @@ -36,8 +36,10 @@ local function update(player)

if node.groups.real_suffocation then -- From real_suffocation mod
combat.time = combat.time + 0.5
combat.suffocation_message = "You are inside blocks. Move out to stop your combat timer from increasing."
else
combat.time = combat.time - 1
combat.suffocation_message = ""
end

combat.timer = minetest.after(1, update, player)
Expand All @@ -56,6 +58,7 @@ function ctf_combat_mode.add_hitter(player, hitter, weapon_image, time)
combat.time = time
combat.last_hitter = hitter
combat.weapon_image = weapon_image
combat.suffocation_message = ""

if not combat.timer then
update(player)
Expand Down

0 comments on commit 5dfebc6

Please sign in to comment.