ToggleObjectRespawn: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
(9 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{ | {{Shared function}} | ||
{{New | {{New feature/item|3.0132|1.3.2|5170| | ||
This function is used to toggle if an object should respawn after it got destroyed | This function is used to toggle if an object should respawn after it got destroyed | ||
}} | }} | ||
{{New feature/item|3.0161|1.6.0|22708|This function is now also available on the server side.}} | |||
{{Note|The object will be respawned when it is streamed}} | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool toggleObjectRespawn( object theObject, bool respawn ) | bool toggleObjectRespawn ( object theObject, bool respawn ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[object]]:toggleRespawn}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theObject''': | *'''theObject''': the object you want to toggle the respawn from | ||
*'''respawn ''': | *'''respawn ''': a bool denoting whether we want to enable (''true'') or disable (''false'') respawning | ||
===Returns=== | ===Returns=== | ||
* ''true'' when the it was changed successfully. | |||
* ''false'' otherwise. | |||
==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== | ||
{{ | {{Shared_object_functions}} |
Latest revision as of 12:11, 4 September 2024
This function is used to toggle if an object should respawn after it got destroyed
Syntax
bool toggleObjectRespawn ( object theObject, bool respawn )
OOP Syntax Help! I don't understand this!
- Method: object:toggleRespawn(...)
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
- true when the it was changed successfully.
- false otherwise.
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