blob: f89e8fc2e8112c2a7a82407805b04a38123956e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
-- playername => time-of-last-cooldown
local cooldown = {}
minetest.register_chatcommand("mesecons_clear_penalty", {
description = "clears the penalty in the current mapblock " ..
"(cooldown: " .. mesecons_debug.penalty_clear_cooldown .. ")",
func = function(name)
local player = minetest.get_player_by_name(name)
if not player then
return
end
local last_cooldown_time = cooldown[name] or 0
local remaining_time = mesecons_debug.penalty_clear_cooldown - (os.time() - last_cooldown_time)
if remaining_time > 0 then
-- cooldown still in progress
return true, "cooldown still in progress, remaining time: " .. remaining_time .. " seconds"
end
-- set timer
cooldown[name] = os.time()
local ctx = mesecons_debug.get_context(player:get_pos())
ctx.penalty = 0
return true, "penalty reset"
end
})
|