call
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function is used to call a function from another resource (which must be running).
Calls (exports) may incur a performance overhead - they are not equivalent in performance to calling functions in the same resource. Do not use exports in render events (like onClientRender ), or in fast processing logic, unless you want to kill performance. The sourceResource and sourceResourceRoot "hidden" variables are available even if you use exports.: Using this function straight away on resource start might cause elements to not be passed properly, use setTimer in order to delay function execution and to avoid this issue.
OOP Syntax Help! I don't understand this!
- Method: resource:call(...)
Syntax
var... call ( resource theResource, string theFunction, unknown arguments... )Required Arguments
- theResource: This is a resource pointer which refers to the resource you are calling a function from.
- theFunction: This is a string with the name of the function which you want to call.
- arguments...: MISSING_PARAM_DESC
Returns
- var...: value
Returns anything that the designated function has returned, if the function has no return, nil is returned. If the function does not exist, is not exported, or the call was not successful it will return false.
Code Examples
This extract shows adding of a "kills" column to the scoreboard resource. This then sets thegameShowKillsvariable to true(or false), telling the rest of the script to start outputting kills.
function showKills ( option ) if not option then -- Remove the "kills" column exports.scoreboard:removeScoreboardColumn("kills") else -- Add the "kills" column exports["scoreboard"]:addScoreboardColumn("kills") outputDebugString ( "Showing kills now..." ) end gameShowKills = optionendSee Also
Resource Functions
- abortRemoteRequest
- addResourceConfig
- addResourceMap
- call
- callRemote
- copyResource
- createResource
- deleteResource
- fetchRemote
- getRemoteRequestInfo
- getRemoteRequests
- getResourceACLRequests
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceGUIElement
- getResourceInfo
- getResourceLastStartTime
- getResourceLoadFailureReason
- getResourceLoadTime
- getResourceMapRootElement
- getResourceName
- getResourceOrganizationalPath
- getResourceRootElement
- getResources
- getResourceState
- getThisResource
- isResourceArchived
- isResourceProtected
- refreshResources
- removeResourceFile
- renameResource
- restartResource
- setResourceInfo
- startResource
- stopResource
- updateResourceACLRequest