InjectResource
Queue Lua code for injection into a target resource's VM.
Syntax
Susano.InjectResource(resourceName, luaCode[, injectionType][, chunkName]) -> void
Parameters
resourceName (string): Target resource name. Use "any" to inject into the first available resource.
luaCode (string): Lua source code to execute inside the target resource's VM.
injectionType (integer, optional): Controls how the code is executed. Default: 1 (NEW_THREAD).
- Susano.NEW_THREAD: Creates a new thread in the resource.
- Susano.NO_THREAD: Runs directly in the first available thread.
chunkName (string, optional): Override the chunk name used when loading the code. Also targets a specific thread running this file. Defaults to "@resourceName/client.lua".
Return(s)
None
Behavior
Queues Lua code for injection into a target resource's Lua VM.
The injection is not immediate: the code is stored and executed when the target resource's VM next runs.
The injected code runs inside the target resource's environment, not Susano's sandbox. Susano.* calls will NOT work inside injected code. You have access to the resource's own globals, natives, and namespaces.
Use Susano.GetInjectableResources() to discover which resources are currently available for injection.
Use Susano.GetResourceFiles(resourceName) to list the Lua files in a resource before injecting.
Example(s)
-- Inject a simple print into a resource
Susano.InjectResource("es_extended", "print('Hello from Susano!')")
-- Inject into any available resource
Susano.InjectResource("any", "print('Injected!')")
-- Inject without creating a thread (NO_THREAD)
Susano.InjectResource("myresource", "print('No thread')", 2)
-- Inject with a specific chunk name to target a file
Susano.InjectResource("myresource", code, Susano.NEW_THREAD, "@myresource/server.lua")