Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nodes.lua #1327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions mods/ctf/ctf_map/nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,15 @@ local chest_def = {
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
if player then
minetest.chat_send_player(player:get_player_name(),
"You're not allowed to put things in treasure chests!")
local meta = player:get_meta()
local last_time_warned = meta:get_int("last_chest_time_warned")
local current_time = minetest.get_gametime()

if current_time - last_time_warned > 0.01 then
minetest.chat_send_player(player:get_player_name(),
"You're not allowed to put things in treasure chests!")
meta:set_int("last_chest_time_warned", current_time)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timer doesn't need to be chest-specific, so for speed's sake instead of storing the current time in meta I would store it in a local table indexed by playername, when a player leaves their entry is removed.

end
return 0
end
end,
Expand Down