Signals
Engine connection inspection, one-shot dispatch and the custom Signal class.
- Engine signals
- getconnections
- firesignal
- defersignal
- cfiresignal
- replicatesignal
- cansignalreplicate
- getsignalwhitelist
- getsignalarguments
- getsignalargumentsinfo
- Connection inspection
- isconnectionenabled
- setconnectionenabled
- isluaconnection
- iswaitingconnection
- getconnectionfunction
- getconnectionthread
- isgamescriptconnection
- ConnectionProxy properties
- ConnectionProxy:Enable
- ConnectionProxy:Disable
- ConnectionProxy:Disconnect
- ConnectionProxy:Fire
- ConnectionProxy:Defer
- ConnectionProxy:SetFunction
- Signal replacement
- hooksignal
- restoresignal
- issignalhooked
- Custom Signal class
- Signal.new
- Signal:Connect
- Signal:Once
- Signal:Wait
- Signal:Fire
- SignalConnection:Disconnect
Engine signal functions take RBXScriptSignal values. The separate Signal.new class below has its own methods and is not accepted by getconnections or the engine-signal helpers.
Engine signals
getconnections
getconnections(signal: RBXScriptSignal): {ConnectionProxy}Returns an array of connection proxies for the engine signal, including Lua, native and waiting connections. The function temporarily creates and disconnects a probe connection.
Also available as get_connections.
firesignal
firesignal(signal: RBXScriptSignal, ...any): ()Invokes the signal Lua connections with the supplied arguments. Uses connection Fire behavior, including disconnecting Once connections before invocation.
Also available as fire_signal.
defersignal
defersignal(signal: RBXScriptSignal, ...any): ()Schedules the signal connections through their Defer methods. Once connections are disconnected when scheduled, so repeated calls do not enqueue them again.
Also available as defer_signal.
cfiresignal
cfiresignal(signal: RBXScriptSignal, ...any): ()Invokes the native event descriptor after converting arguments to the declared event types. Invalid signal storage, types or event entry points raise an error. This is distinct from invoking only Lua connection proxies.
Also available as c_fire_signal.
replicatesignal
replicatesignal(signal: RBXScriptSignal, ...any): ()Requests native event invocation through the owning Object using the event signature. Numeric values are converted for declared integer/float arguments. The native replication policy determines the outcome.
Also available as replicate_signal.
cansignalreplicate
cansignalreplicate(signal: RBXScriptSignal): booleanQueries the native signal replication policy. Returns false if the policy query fails.
Also available as can_signal_replicate, issignalreplicateable and is_signal_replicateable.
getsignalwhitelist
getsignalwhitelist(): {{Parent: string, Event: string}}Returns the current native compatibility-list candidates as class/event name records. The list is created from the active native descriptor policy, not a fixed list of event names.
Also available as get_signal_whitelist.
getsignalarguments
getsignalarguments(signal: RBXScriptSignal): {string}Returns declared event argument type names in order. Returns an empty array when no descriptor argument list exists.
Also available as get_signal_arguments.
getsignalargumentsinfo
getsignalargumentsinfo(signal: RBXScriptSignal): {{Type: string, Name: string}}Returns argument type/name records in order. A missing argument name falls back to its type name.
Also available as get_signal_arguments_info.
Connection inspection
isconnectionenabled
isconnectionenabled(connection: ConnectionProxy): booleanReturns whether a live connection is enabled; returns false for a stale proxy.
Also available as is_connection_enabled.
setconnectionenabled
setconnectionenabled(connection: ConnectionProxy, enabled: boolean): ()Enables or disables a live connection; a stale proxy is ignored.
Also available as set_connection_enabled.
isluaconnection
isluaconnection(connection: ConnectionProxy): booleanReturns whether the proxy represents a Lua rather than native connection.
Also available as is_lua_connection.
iswaitingconnection
iswaitingconnection(connection: ConnectionProxy): booleanReturns whether the Lua connection represents a thread waiting for the event.
Also available as is_waiting_connection.
getconnectionfunction
getconnectionfunction(connection: ConnectionProxy, raw: boolean?): anyReturns the stored callback when raw is true. Otherwise returns a function, a callable table __call function, or nil. raw defaults to false. Native/waiting connections raise Invalid connection; stale and foreign-VM callbacks return nil.
Also available as get_connection_function.
getconnectionthread
getconnectionthread(connection: ConnectionProxy): thread?Returns the live owning thread when it belongs to the current VM, otherwise nil. Native connections raise Invalid connection.
Also available as get_connection_thread.
isgamescriptconnection
isgamescriptconnection(connection: ConnectionProxy): booleanReturns whether a live Lua connection has a source script that is not a CoreScript. Native, stale and unavailable source connections return false.
Also available as is_game_script_connection.
ConnectionProxy properties
ConnectionProxy:Enable
ConnectionProxy:Enable(): ()Enables this live connection.
ConnectionProxy:Disable
ConnectionProxy:Disable(): ()Disables this live connection without destroying it.
ConnectionProxy:Disconnect
ConnectionProxy:Disconnect(): ()Disconnects this connection and invalidates aliases to the same slot.
ConnectionProxy:Fire
ConnectionProxy:Fire(...any): ()Invokes the stored callback or resumes a waiting thread. Once connections are disconnected before invocation. A stale connection has no effect.
ConnectionProxy:Defer
ConnectionProxy:Defer(...any): ()Schedules invocation through task.defer. A Once connection is disconnected before scheduling.
ConnectionProxy:SetFunction
ConnectionProxy:SetFunction(callback: function): ()Replaces the callback of a live Lua connection. Native/stale connections raise Invalid callback.
Signal replacement
hooksignal
hooksignal(signal: RBXScriptSignal, callback: (...any) -> ()): (...any) -> ...anyReplaces eligible signal connection callbacks with callback, which receives the original event arguments. Returns a dispatcher for the original connection currently being handled. A second registration raises Signal already registered. Save the returned dispatcher if the replacement should forward the event.
Also available as hook_signal.
restoresignal
restoresignal(signal: RBXScriptSignal): ()Restores connection callback/thread state owned by the registered replacement and removes its record. Does nothing if the signal has no record.
Also available as restore_signal.
issignalhooked
issignalhooked(signal: RBXScriptSignal): booleanReturns whether the signal currently has a module replacement record.
Also available as is_signal_hooked.
Custom Signal class
Signal.new
Signal.new(): SignalCreates an independent module Signal. It exposes Connect, Once, Wait and Fire; it has no public Destroy method. Dropping the signal releases callbacks and waiters when its userdata is collected.
Signal:Connect
Signal:Connect(callback: (...any) -> ()): SignalConnectionConnects a callback and returns a module SignalConnection. This is not an engine RBXScriptConnection.
Signal:Once
Signal:Once(callback: (...any) -> ()): SignalConnectionConnects a callback that disconnects before the first invocation, including recursive Fire calls.
Signal:Wait
YieldsSignal:Wait(): ...anyYields the calling thread until the next fire and returns its event arguments. Raises Thread is not yieldable when called outside a yieldable thread.
Signal:Fire
Signal:Fire(...any): ()Schedules connected callbacks and resumes current waiters with the supplied arguments. Signals returned by DrawingImmediate.GetPaint are native-only and reject manual Fire calls.
SignalConnection:Disconnect
SignalConnection:Disconnect(): ()Disconnects the custom Signal callback. Repeated calls have no effect. This class exposes no public Connected property.
Written for Lynx 0.0.0
Something unclear? Tell us on Discord