OnResourceLoadStateChange: Difference between revisions
Jump to navigation
Jump to search
(Add onResourceLoadStateChange event by TeteX1.) |
Fernando187 (talk | contribs) (Remove obsolete Requirements section) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Server event}} | {{Server event}} | ||
{{ | {{Added feature/item|1.5.9|1.5.8|20809|This event is triggered when a [[resource]] load state is changed.}} | ||
__NOTOC__ | __NOTOC__ | ||
==Parameters== | ==Parameters== | ||
Line 7: | Line 7: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
*'''changedResource''': | *'''changedResource''': The [[resource]] that was either loaded, reloaded or is unloading. | ||
*'''oldState''': | *'''oldState''': The state the [[resource]] was in before it changed. | ||
*'''newState''': | *'''newState''': The state the [[resource]] has changed to. | ||
==Source== | ==Source== | ||
Line 15: | Line 15: | ||
==Example== | ==Example== | ||
This code will output the state of resource when it's state will be changed: | |||
This code will output the state of resource when it's state will be changed | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function onResourceLoadStateChange(resource, oldState, newState) | function onResourceLoadStateChange (resource, oldState, newState) | ||
print ("Resource "..getResourceName (resource).." has changed it's state from "..tostring (oldState).." to "..tostring (newState)) | |||
end | end | ||
addEventHandler("onResourceLoadStateChange", root, onResourceLoadStateChange) | |||
addEventHandler ("onResourceLoadStateChange", root, onResourceLoadStateChange) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{See also/Server event|Resource events}} | {{See also/Server event|Resource events}} |
Latest revision as of 17:26, 7 November 2024
This event is triggered when a resource load state is changed.
Parameters
resource changedResource, string oldState, string newState
- changedResource: The resource that was either loaded, reloaded or is unloading.
- oldState: The state the resource was in before it changed.
- newState: The state the resource has changed to.
Source
The source of this event is the root element.
Example
This code will output the state of resource when it's state will be changed:
function onResourceLoadStateChange (resource, oldState, newState) print ("Resource "..getResourceName (resource).." has changed it's state from "..tostring (oldState).." to "..tostring (newState)) end addEventHandler ("onResourceLoadStateChange", root, onResourceLoadStateChange)
See Also
Resource events
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled