SetTrainDirection: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 15: Line 15:


==Example==
==Example==
This function will make a train driving clockwise.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
This function will make a train driving clockwise.
 
[lua]
function createTain(source)
function createTain(source)
local myTrain = createVehicle(537,1995,-1949,13)  -- Create the train
local myTrain = createVehicle(537,1995,-1949,13)  -- Create the train

Revision as of 13:02, 27 February 2012

Sets the direction in which a train or tram drives over the rails (clockwise or counterclockwise).

Syntax

bool setTrainDirection ( vehicle train, bool clockwise )

Required Arguments

  • train: the train whose direction to change.
  • clockwise: if true, will make the train go clockwise. If false, makes it go counterclockwise.

Returns

Returns true if successful, false otherwise.

Example

This function will make a train driving clockwise.


function createTain(source)
	local myTrain = createVehicle(537,1995,-1949,13)  -- Create the train
	setTrainDirection(myTrain, true) -- Make the train drive clockwise
        setTrainSpeed(myTrain, 1) -- Speed up
end
addCommandHandler("mytrain", createTrain)

See Also