Files
fulpstation/lua/handler_group.lua
A miscellaneous Fern 9bd86e85b5 June/July TGU: Loadout menu, flatpackers and... whatever else! (#1230)
* Initial Commit

* Not quite all was staged, apparently.

* Multiline no longer necessary

* For my convenience...

* Forgot an important little tidbit in routes.tsx

* This updated, apparently.

* And now hell breaks loose

* First batch

* Second Batch

* Third batch (Unit Tests)

* Improvised shotgun ammo is gone; Vibebots are refactored

* UpdatePath sweeps in our fulp_modules/_maps folder

* I can't bring myself to do it.

* Map stuff

* Didn't mean to leave this uncommented

* I carpet-bombed them with Find-Replace. Let's see what linters think

* I sure do hope this is comprehensive and doesn't break other things

* This may take a while

* Next Round

* Hopefully the last batch before getting on with actual fixes

* Telescreens

* :/

* Stragglers

* Helio Emergency Shuttle; NearStation adjustments.

* Only one more commit for greenchecks... Shuttle code be dammed.

* Pff, the file was missing

* Same treatment as the other map files.

* Missed a comma :P

* BZ chambers for Xenobiology

* Odd. Most of these got done earlier. Not sure why this one wasn't.

* Mapping sweep. I didn't adjust C_tags in Theia. Another time.

* The balloon alerts overlap

* I hate TGU I hate TGU

* I meant to say "I hate TG" on the last one. Freudian slip.

* Fix Fix

* Nanite research cost rebalance

* TGU-Update: Step 0

* Yeah I figured it'd do this.

* I accidentally undid this

* Failed to catch this one

* I don't trust hundredths not to break or be broken somewhere.

* Little air alarm tweaks

* Ports #1228

* Stuff I missed

* Silly

* TGU so nice we're going to make it thrice

* Yarn

* Should be all? Fixes cult stun too.

* Thermomachine layers

* Free square spellcheck to rerun tests and see if it's consistent

* All credit goes to QLA for reminding me to actually do this

* Update to e40becd742

* github folder
2024-08-06 20:17:51 -04:00

49 lines
1.3 KiB
Lua

local SS13 = require("SS13")
local HandlerGroup = {}
HandlerGroup.__index = HandlerGroup
function HandlerGroup.new()
return setmetatable({
registered = {},
}, HandlerGroup)
end
-- Registers a signal on a datum for this handler group instance.
function HandlerGroup:register_signal(datum, signal, func)
local registered_successfully = SS13.register_signal(datum, signal, func)
if not registered_successfully then
return
end
table.insert(self.registered, { datum = datum, signal = signal, func = func })
end
-- Clears all the signals that have been registered on this HandlerGroup
function HandlerGroup:clear()
for _, data in self.registered do
if not data.func or not SS13.is_valid(data.datum) then
continue
end
SS13.unregister_signal(data.datum, data.signal, data.func)
end
table.clear(self.registered)
end
-- Clears all the signals that have been registered on this HandlerGroup when a specific signal is sent on a datum.
function HandlerGroup:clear_on(datum, signal, func)
SS13.register_signal(datum, signal, function(...)
if func then
func(...)
end
self:clear()
end)
end
-- Registers a signal on a datum and clears it after it is called once.
function HandlerGroup.register_once(datum, signal, func)
local callback = HandlerGroup.new()
callback:clear_on(datum, signal, func)
return callback
end
return HandlerGroup