ToggleObjectRespawn: Difference between revisions
Jump to navigation
Jump to search
(Added to the needs example category) |
(Added example) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Client function}} | {{Client function}} | ||
Line 23: | Line 22: | ||
==Example== | ==Example== | ||
This example adds command ''tos'' that toggles respawn of all the objects. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local respawn = false | |||
addCommandHandler("tos", | |||
function () | |||
for i, object in pairs(getElementsByType("object")) do | |||
toggleObjectRespawn(object, not respawn) | |||
end | |||
outputChatBox("Object respawning " .. (respawn and "disabled" or "enabled")) | |||
respawn = not respawn | |||
end) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Client_object_functions}} | {{Client_object_functions}} |
Revision as of 16:55, 19 May 2014
This function is used to toggle if an object should respawn after it got destroyed
Syntax
bool toggleObjectRespawn( object theObject, bool respawn )
Required Arguments
- theObject: The object you want to toggle the respawn from
- respawn : A bool denoting whether we want to enable (true) or disable (false) respawning
Returns
Returns true when the it was changed successfully, or false otherwise.
Requirements
Minimum server version | n/a |
---|---|
Minimum client version | 1.4 |
Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version client="1.4" />
Example
This example adds command tos that toggles respawn of all the objects.
local respawn = false addCommandHandler("tos", function () for i, object in pairs(getElementsByType("object")) do toggleObjectRespawn(object, not respawn) end outputChatBox("Object respawning " .. (respawn and "disabled" or "enabled")) respawn = not respawn end)
See Also
- breakObject
- getObjectMass
- getObjectProperty
- isObjectMoving
- respawnObject
- setObjectMass
- setObjectProperty
- toggleObjectRespawn
Shared