I'm not exactly sure I did it correctly (I'm not a modder), but it works and is what I needed.
local function onTick()
local tick_count = settings.startup["tick_count"].value
for _, control in pairs(storage.deactivating_buttons) do
if control.valid then
control.enabled = false
end
end
storage.deactivating_buttons = {}
for i, control in pairs(storage.activating_buttons) do
if control.valid then
control.enabled = true
if control.entity.name == "bigswitchbutton2" then
storage.deactivating_buttons[i] = control
end
end
end
if (game.tick % tick_count) == 0 then
storage.activating_buttons = {}
if next(storage.deactivating_buttons) == nil then
-- all buttons done, unregister the handler
script.on_event(defines.events.on_tick, nil)
end
end
end
And accordingly, the settings:
{
type = "int-setting",
name = "tick_count",
setting_type = "startup",
default_value = 60,
minimum_value = 1,
maximum_value = 99999,
order = "z",
},
Now the button gives a signal lasting 60 ticks (sometimes for some reason shorter than 60 ticks), but this is enough to not miss the signal.