GetVehicleTurretPosition: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
(Corrected "Returns" field and the example. Removed the "Needs checking" messages) |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server client 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. | This function gets the position of a vehicle's turret, if it has one. Vehicles with turrets include firetrucks and tanks. | ||
Line 12: | Line 10: | ||
===Returns=== | ===Returns=== | ||
Returns two [[float]]s for the X (horizontal) and Y (vertical) axis rotation respectively. These values are in radians. The function will return '' | 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== | ||
Line 22: | Line 20: | ||
-- Get the vehicle's turret position | -- Get the vehicle's turret position | ||
local x, y = getVehicleTurretPosition ( vehicleValue ) | 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 | end | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 10:16, 8 November 2010
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 )
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