StopObject: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
SaintsTalles (talk | contribs) |
||
(27 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client function}} | |||
This | This will allow you to stop an object that is currently moving. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool stopObject ( object theObject ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
{{OOP||[[object]]:stop||}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''theObject:''' the [[object]] whose movement you wish to stop | |||
*''' | |||
===Returns=== | ===Returns=== | ||
* ''true'' if successful. | |||
* ''false'' otherwise. | |||
==Example== | ==Example== | ||
This will allow you to toggle the random movement of a staircase object model using a ''randomObjectMovement'' function and stop it immediately with the stopObject command. This is achieved by using a "toggleobjectmove" command with a "on" or "off" parameter. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | function objectMoveControl ( thePlayer, commandName, state ) | ||
-- On "toggleobjectmove" in console, activate this command, which also asks the player to define the value for the varible 'state'. | |||
-- | if state == "on" then | ||
outputChatBox ( "Moving object randomly" ) | |||
mytimer = setTimer ( randomObjectMovement, 2250, 0 ) | |||
-- if the player types "on" for the state variable, turn on the timer, which triggers a function | |||
-- called randomObjectMovement that moves the object whenever it is called (not included for | |||
-- this example). The timer runs every 2 1/4 seconds for 0 times, which means it runs infinitely. | |||
elseif state == "off" then | |||
outputChatBox ( "Stopping object movement" ) | |||
killTimer ( mytimer ) | |||
stopObject ( myobject ) | |||
-- if the player typed "off" for state, stop the object movement immediately and kill the | |||
-- randomObjectMovement timer | |||
else | |||
outputChatBox ( "must define object state as 'on' or 'off'" ) | |||
-- if the player typed something besides "on" or "off" for state, do nothing | |||
end | |||
end | |||
addCommandHandler ( "toggleobjectmove", objectMoveControl ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Object_functions}} | |||
{{ | |||
Latest revision as of 12:08, 31 October 2023
This will allow you to stop an object that is currently moving.
Syntax
bool stopObject ( object theObject )
OOP Syntax Help! I don't understand this!
- Method: object:stop(...)
Required Arguments
- theObject: the object whose movement you wish to stop
Returns
- true if successful.
- false otherwise.
Example
This will allow you to toggle the random movement of a staircase object model using a randomObjectMovement function and stop it immediately with the stopObject command. This is achieved by using a "toggleobjectmove" command with a "on" or "off" parameter.
function objectMoveControl ( thePlayer, commandName, state ) -- On "toggleobjectmove" in console, activate this command, which also asks the player to define the value for the varible 'state'. if state == "on" then outputChatBox ( "Moving object randomly" ) mytimer = setTimer ( randomObjectMovement, 2250, 0 ) -- if the player types "on" for the state variable, turn on the timer, which triggers a function -- called randomObjectMovement that moves the object whenever it is called (not included for -- this example). The timer runs every 2 1/4 seconds for 0 times, which means it runs infinitely. elseif state == "off" then outputChatBox ( "Stopping object movement" ) killTimer ( mytimer ) stopObject ( myobject ) -- if the player typed "off" for state, stop the object movement immediately and kill the -- randomObjectMovement timer else outputChatBox ( "must define object state as 'on' or 'off'" ) -- if the player typed something besides "on" or "off" for state, do nothing end end addCommandHandler ( "toggleobjectmove", objectMoveControl )
See Also