SetTrainPosition: Difference between revisions
Jump to navigation
Jump to search
m (comment code, fix example bug) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Shared function}} | {{Shared function}} | ||
{{New feature/item|3. | {{New feature/item|3.0153|1.5.3|7485| | ||
Sets the position the train is currently on the track | Sets the position the train is currently on the track | ||
}} | }} | ||
Line 10: | Line 10: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''train:''' the train of which to set the track | *'''train:''' the train of which to set the track | ||
*'''position:''' the position along the track | *'''position:''' the position along the track (0 - 18107 a complete way round) | ||
===Returns=== | ===Returns=== | ||
Line 40: | Line 40: | ||
if not position then | if not position then | ||
player:outputChat("Syntax: /settrainpos <position>") | player:outputChat("Syntax: /settrainpos <position>") | ||
return | return | ||
end | end |
Latest revision as of 18:37, 16 March 2019
Sets the position the train is currently on the track
Syntax
bool setTrainPosition ( vehicle train, float position )
OOP Syntax Help! I don't understand this!
- Method: vehicle:setTrainPosition(...)
- Variable: .trainPosition
- Counterpart: getTrainPosition
Required Arguments
- train: the train of which to set the track
- position: the position along the track (0 - 18107 a complete way round)
Returns
Returns true if the train position was set, false otherwise.
Example
Click to collapse [-]
OOP Example 1This example adds a command called "/settrainpos", allowing you to set the position of the train.
local function setMyPosition(player, _, position) -- grab the vehicle, if it exists local veh = player.vehicle -- make sure we're actually in a vehicle if not veh then player:outputChat("You are not in a vehicle!") return end -- make sure we're in a train if veh.vehicleType ~= "Train" then player:outputChat("You are not in a train!") return end -- convert position to a number position = tonumber(position) -- if position cannot be converted to a number if not position then player:outputChat("Syntax: /settrainpos <position>") return end -- finally set the train position veh.trainPosition = position end addCommandHandler("settrainpos", setMyPosition)
See Also
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates