mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
Renamed GetVehSpeedFormatted to GetVehSpeedConverted
Also, more comments
This commit is contained in:
29
cl_radar.lua
29
cl_radar.lua
@@ -471,7 +471,7 @@ end
|
|||||||
-- Sets the patrol speed to a formatted version of the given number
|
-- Sets the patrol speed to a formatted version of the given number
|
||||||
function RADAR:SetPatrolSpeed( speed )
|
function RADAR:SetPatrolSpeed( speed )
|
||||||
if ( type( speed ) == "number" ) then
|
if ( type( speed ) == "number" ) then
|
||||||
self.vars.patrolSpeed = self:GetVehSpeedFormatted( speed )
|
self.vars.patrolSpeed = self:GetVehSpeedConverted( speed )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1009,7 +1009,7 @@ end
|
|||||||
Radar functions
|
Radar functions
|
||||||
----------------------------------------------------------------------------------]]--
|
----------------------------------------------------------------------------------]]--
|
||||||
-- Takes a GTA speed and converts it into the type defined by the user in the operator menu
|
-- Takes a GTA speed and converts it into the type defined by the user in the operator menu
|
||||||
function RADAR:GetVehSpeedFormatted( speed )
|
function RADAR:GetVehSpeedConverted( speed )
|
||||||
-- Get the speed unit from the settings
|
-- Get the speed unit from the settings
|
||||||
local unit = self:GetSettingValue( "speedType" )
|
local unit = self:GetSettingValue( "speedType" )
|
||||||
|
|
||||||
@@ -1308,7 +1308,7 @@ function RADAR:Main()
|
|||||||
if ( entSpeed == 0 ) then
|
if ( entSpeed == 0 ) then
|
||||||
data.patrolSpeed = "¦[]"
|
data.patrolSpeed = "¦[]"
|
||||||
else
|
else
|
||||||
local speed = self:GetVehSpeedFormatted( entSpeed )
|
local speed = self:GetVehSpeedConverted( entSpeed )
|
||||||
data.patrolSpeed = UTIL:FormatSpeed( speed )
|
data.patrolSpeed = UTIL:FormatSpeed( speed )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1321,21 +1321,32 @@ function RADAR:Main()
|
|||||||
for ant in UTIL:Values( { "front", "rear" } ) do
|
for ant in UTIL:Values( { "front", "rear" } ) do
|
||||||
-- Check that the antenna is actually transmitting, no point in running all the checks below if the antenna is off
|
-- Check that the antenna is actually transmitting, no point in running all the checks below if the antenna is off
|
||||||
if ( self:IsAntennaTransmitting( ant ) ) then
|
if ( self:IsAntennaTransmitting( ant ) ) then
|
||||||
--
|
-- Create a table for the current antenna to store the information
|
||||||
data.antennas[ant] = {}
|
data.antennas[ant] = {}
|
||||||
|
|
||||||
for i = 1, 2 do
|
-- When the system works out what vehicles to be used, both the "front" and "rear" keys have two items located
|
||||||
|
-- at index 1 and 2. Index 1 stores the vehicle data for the antenna's 'strongest' vehicle, and index 2 stores
|
||||||
|
-- the vehicle data for the 'fastest' vehicle. Here we iterate through both the indexes and just run checks to
|
||||||
|
-- see if it is a particular type (e.g. if i % 2 == 0 then it's the 'fastest' vehicle)
|
||||||
|
for i = 1, 2 do
|
||||||
|
-- Create the table to store the speed and direction for this vehicle data
|
||||||
data.antennas[ant][i] = { speed = "¦¦¦", dir = 0 }
|
data.antennas[ant][i] = { speed = "¦¦¦", dir = 0 }
|
||||||
|
|
||||||
|
-- If the current iteration is the number 2 ('fastest') and there's a speed locked, grab the locked speed
|
||||||
|
-- and direction
|
||||||
if ( i == 2 and self:IsAntennaSpeedLocked( ant ) ) then
|
if ( i == 2 and self:IsAntennaSpeedLocked( ant ) ) then
|
||||||
data.antennas[ant][i].speed = self.vars.antennas[ant].lockedSpeed
|
data.antennas[ant][i].speed = self.vars.antennas[ant].lockedSpeed
|
||||||
data.antennas[ant][i].dir = self.vars.antennas[ant].lockedDir
|
data.antennas[ant][i].dir = self.vars.antennas[ant].lockedDir
|
||||||
|
|
||||||
|
-- Otherwise, continue with getting speed and direction data
|
||||||
else
|
else
|
||||||
-- The vehicle data exists for this slot
|
-- The vehicle data exists for this slot
|
||||||
if ( av[ant][i] ~= nil ) then
|
if ( av[ant][i] ~= nil ) then
|
||||||
-- We already have the vehicle speed as we needed it earlier on for filtering
|
-- Here we get the entity speed of the vehicle, the speed for this vehicle would've been obtained
|
||||||
local uSpeed = GetEntitySpeed( av[ant][i].veh )
|
-- and stored in the trace stage, but the speed would've only been obtained and stored once, which
|
||||||
data.antennas[ant][i].speed = UTIL:FormatSpeed( self:GetVehSpeedFormatted( uSpeed ) )
|
-- means that it woulsn't be the current speed
|
||||||
|
local vehSpeed = GetEntitySpeed( av[ant][i].veh )
|
||||||
|
data.antennas[ant][i].speed = UTIL:FormatSpeed( self:GetVehSpeedConverted( vehSpeed ) )
|
||||||
|
|
||||||
-- Work out if the vehicle is closing or away
|
-- Work out if the vehicle is closing or away
|
||||||
local ownH = UTIL:Round( GetEntityHeading( PLY.veh ), 0 )
|
local ownH = UTIL:Round( GetEntityHeading( PLY.veh ), 0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user