Resource
Quick Reference
| Name | Type | Description |
|---|---|---|
| GetState | Shared | Returns the state of the specified resource. |
| GetCurrentName | Shared | Returns the name of the currently executing resource. |
| Call | Shared | Calls an exported function in the specified resource. |
| Start | Server | Start a resource. |
| Stop | Server | Stop a resource. |
| Restart | Server | Restart a resource. |
Shared Functions
GetState
Returns the state of the specified resource.
string state = Resource.GetState(string resource)
info
Possible states are:
"unknown"
"started"
"loaded"
"stopped"
A resource inside a category folder is addressed by its full name,
e.g. "gamemodes/freeroam". The same goes for every other function on this page.
GetCurrentName
Returns the name of the currently executing resource.
string resource = Resource.GetCurrentName()
Call
Calls an exported function in the specified resource and returns whatever that function returned.
any ... = Resource.Call(string resource, string function, list arguments)
warning
tip
The exports table is a shorter way to write the same call.
Example:
- Lua
- JavaScript
- Squirrel (deprecated)
local res1, res2 = Resource.Call("myResource", "myFunction", { 8, 16 })
// One value when the function returns one, an array when it returns several (Lua only).
const [res1, res2] = Resource.Call("myResource", "myFunction", [ 8, 16 ]);
local res = Resource.Call("myResource", "myFunction", [ 8, 16 ]);