GetVehicleTurretPosition: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(OOP) |
||
(15 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This function | {{Server client function}} | ||
This function gets the position of a vehicle's turret, if it has one. Vehicles with turrets include firetrucks and tanks. | |||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua">float float getVehicleTurretPosition ( vehicle )</syntaxhighlight> | <syntaxhighlight lang="lua">float, float getVehicleTurretPosition ( vehicle turretVehicle )</syntaxhighlight> | ||
{{OOP||[[vehicle]]:getTurretPosition|turretPosition|setVehicleTurretPosition}} | |||
{{ | |||
===Required Arguments=== | ===Required Arguments=== | ||
*''' | *'''turretVehicle''': The [[vehicle]] whose turret position you want to retrieve. This should be a vehicle with a turret. | ||
===Returns=== | ===Returns=== | ||
Returns two [[float]]s for the X and Y axis rotation respectively. | Returns two [[float]]s for the X (horizontal) and Y (vertical) axis rotation respectively. These values are in radians. The function will return ''0, 0'' if the vehicle is not a vehicle with a turret. | ||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
x, y = | -- Find all the vehicles, and store them in a vehicles variable | ||
if (x) | local vehicles = getElementsByType ( "vehicle" ) | ||
-- Loop through the vehicle list | |||
end</syntaxhighlight> | for vehicleKey, vehicleValue in ipairs(vehicles) do | ||
-- Get the vehicle's turret position | |||
local x, y = getVehicleTurretPosition ( vehicleValue ) | |||
-- Convert the positions to degrees, as that's much more useful if you'd want to output it | |||
x = math.deg ( x ) | |||
y = math.deg ( y ) | |||
-- Get the vehicle's name | |||
local vehicleName = getVehicleName ( vehicleValue ) | |||
-- Tell everyone in the F8 console the turret's position | |||
outputConsole ( vehicleName .. "'s turret rotation: " .. x .. ", " .. y .. "." ) | |||
end | |||
</syntaxhighlight> | |||
==See Also== | |||
{{Vehicle functions}} |
Latest revision as of 23:35, 17 December 2014
This function gets the position of a vehicle's turret, if it has one. Vehicles with turrets include firetrucks and tanks.
Syntax
float, float getVehicleTurretPosition ( vehicle turretVehicle )
OOP Syntax Help! I don't understand this!
- Method: vehicle:getTurretPosition(...)
- Variable: .turretPosition
- Counterpart: setVehicleTurretPosition
Required Arguments
- turretVehicle: The vehicle whose turret position you want to retrieve. This should be a vehicle with a turret.
Returns
Returns two floats for the X (horizontal) and Y (vertical) axis rotation respectively. These values are in radians. The function will return 0, 0 if the vehicle is not a vehicle with a turret.
Example
-- Find all the vehicles, and store them in a vehicles variable local vehicles = getElementsByType ( "vehicle" ) -- Loop through the vehicle list for vehicleKey, vehicleValue in ipairs(vehicles) do -- Get the vehicle's turret position local x, y = getVehicleTurretPosition ( vehicleValue ) -- Convert the positions to degrees, as that's much more useful if you'd want to output it x = math.deg ( x ) y = math.deg ( y ) -- Get the vehicle's name local vehicleName = getVehicleName ( vehicleValue ) -- Tell everyone in the F8 console the turret's position outputConsole ( vehicleName .. "'s turret rotation: " .. x .. ", " .. y .. "." ) end
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