Cooldown for dispensers and droppers (#4814)

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4814
Reviewed-by: teknomunk <teknomunk@protonmail.com>
Co-authored-by: kno10 <erich.schubert@gmail.com>
Co-committed-by: kno10 <erich.schubert@gmail.com>
This commit is contained in:
kno10 2025-01-05 15:43:04 +01:00 committed by the-real-herowl
parent 1521d202aa
commit 3d862a0336
2 changed files with 12 additions and 0 deletions

View File

@ -11,6 +11,9 @@ local S = minetest.get_translator(minetest.get_current_modname())
local C = minetest.colorize
local F = minetest.formspec_escape
-- TODO: actually should have a slight lag as in MC?
local COOLDOWN = 0.19
local dispenser_formspec = table.concat({
"formspec_version[4]",
"size[11.75,10.425]",
@ -113,6 +116,9 @@ local dispenserdef = {
-- Dispense random item when triggered
action_on = function(pos, node)
local meta = minetest.get_meta(pos)
local gametime = core.get_gametime()
if gametime < meta:get_float("cooldown") then return end
meta:set_float("cooldown", gametime + COOLDOWN)
local inv = meta:get_inventory()
local droppos, dropdir
if node.name == "mcl_dispensers:dispenser" then

View File

@ -12,6 +12,9 @@ local S = minetest.get_translator(minetest.get_current_modname())
local C = minetest.colorize
local F = minetest.formspec_escape
-- TODO: actually should have a slight lag as in MC?
local COOLDOWN = 0.19
local dropper_formspec = table.concat({
"formspec_version[4]",
"size[11.75,10.425]",
@ -113,6 +116,9 @@ local dropperdef = {
action_on = function(pos, node)
if not pos then return end
local meta = minetest.get_meta(pos)
local gametime = core.get_gametime()
if gametime < meta:get_float("cooldown") then return end
meta:set_float("cooldown", gametime + COOLDOWN)
local inv = meta:get_inventory()
local droppos
if node.name == "mcl_droppers:dropper" then