From 27455e51dd774203ec3fc33881e5badadd0fb415 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 27 Feb 2020 16:13:16 +0000 Subject: [PATCH] Operator menu defaults can now be set in the config --- cl_radar.lua | 57 +++++++++++++++++++++++++++++++++++++--------------- config.lua | 39 +++++++++++++++++++++++++++++++---- 2 files changed, 76 insertions(+), 20 deletions(-) diff --git a/cl_radar.lua b/cl_radar.lua index 7d556f6..b94e4d2 100644 --- a/cl_radar.lua +++ b/cl_radar.lua @@ -106,23 +106,23 @@ RADAR.vars = -- These are the settings that are used in the operator menu settings = { -- Should the system calculate and display faster targets - ["fastDisplay"] = true, + ["fastDisplay"] = CONFIG.menuDefaults["fastDisplay"], - -- Sensitivty for each radar mode, this changes how far the antennas will detect vehicles - ["same"] = 3, - ["opp"] = 3, + -- Sensitivity for each radar mode, this changes how far the antennas will detect vehicles + ["same"] = CONFIG.menuDefaults["same"], + ["opp"] = CONFIG.menuDefaults["opp"], -- The volume of the audible beep - ["beep"] = 0.6, + ["beep"] = CONFIG.menuDefaults["beep"], -- The volume of the verbal lock confirmation - ["voice"] = 0.6, + ["voice"] = CONFIG.menuDefaults["voice"], -- The volume of the plate reader audio - ["plateAudio"] = 0.6, + ["plateAudio"] = CONFIG.menuDefaults["plateAudio"], -- The speed unit used in conversions - ["speedType"] = "mph" + ["speedType"] = CONFIG.menuDefaults["speedType"] }, -- These 3 variables are for the in-radar menu that can be accessed through the remote control, the menuOptions table @@ -130,13 +130,13 @@ RADAR.vars = menuActive = false, currentOptionIndex = 1, menuOptions = { - { displayText = { "¦¦¦", "FAS" }, optionsText = { "On¦", "Off" }, options = { true, false }, optionIndex = 1, settingText = "fastDisplay" }, - { displayText = { "¦SL", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 3, settingText = "same" }, - { displayText = { "¦OP", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 3, settingText = "opp" }, - { displayText = { "bEE", "P¦¦" }, optionsText = { "Off", "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 4, settingText = "beep" }, - { displayText = { "VOI", "CE¦" }, optionsText = { "Off", "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 4, settingText = "voice" }, - { displayText = { "PLt", "AUd" }, optionsText = { "Off", "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 4, settingText = "plateAudio" }, - { displayText = { "Uni", "tS¦" }, optionsText = { "USA", "INT" }, options = { "mph", "kmh" }, optionIndex = 1, settingText = "speedType" } + { displayText = { "¦¦¦", "FAS" }, optionsText = { "On¦", "Off" }, options = { true, false }, optionIndex = -1, settingText = "fastDisplay" }, + { displayText = { "¦SL", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = -1, settingText = "same" }, + { displayText = { "¦OP", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = -1, settingText = "opp" }, + { displayText = { "bEE", "P¦¦" }, optionsText = { "Off", "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = -1, settingText = "beep" }, + { displayText = { "VOI", "CE¦" }, optionsText = { "Off", "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = -1, settingText = "voice" }, + { displayText = { "PLt", "AUd" }, optionsText = { "Off", "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = -1, settingText = "plateAudio" }, + { displayText = { "Uni", "tS¦" }, optionsText = { "USA", "INT" }, options = { "mph", "kmh" }, optionIndex = -1, settingText = "speedType" } }, -- Player's vehicle speed, mainly used in the dynamic thread wait update @@ -377,6 +377,28 @@ function RADAR:OpenRemote() end end +-- Updates the operator menu option indexes, as the default menu values can be changed in the config, we +-- need to update the indexes otherwise the menu will display the wrong values +function RADAR:UpdateOptionIndexes() + -- Iterate through each of the internal settings + for k, v in pairs( self.vars.settings ) do + -- Iterate through all of the menu options + for i, t in pairs( self.vars.menuOptions ) do + -- If the current menu option is the same as the current setting + if ( t.settingText == k ) then + -- Iterate through the option values of the current menu option + for oi, ov in pairs( t.options ) do + -- If the value of the current option set in the config matches the current value of + -- the option value, then we update the option index variable + if ( v == ov ) then + t.optionIndex = oi + end + end + end + end + end +end + -- Returns if the fast limit option should be available for the radar function RADAR:IsFastLimitAllowed() return CONFIG.allow_fast_limit @@ -1574,7 +1596,10 @@ Citizen.CreateThread( function() RADAR:CacheNumRays() -- Update the end coordinates for the ray traces based on the config, again, reduced hard coding - RADAR:UpdateRayEndCoords() + RADAR:UpdateRayEndCoords() + + -- Update the operator menu positions + RADAR:UpdateOptionIndexes() -- If the fast limit feature is allowed, create the config in the radar variables if ( RADAR:IsFastLimitAllowed() ) then diff --git a/config.lua b/config.lua index 6159544..757173f 100644 --- a/config.lua +++ b/config.lua @@ -8,6 +8,12 @@ -- Do not touch this CONFIG = {} +-- Radar fast limit locking +-- When enabled, the player will be able to define a fast limit within the radar's menu, when a vehicle +-- exceeds the fast limit, it will be locked into the fast box. Default setting is disabled to maintain realism +CONFIG.allow_fast_limit = true + +-- Sets all of the controls CONFIG.keys = { -- Remote control key @@ -61,7 +67,32 @@ CONFIG.keys = } } --- Radar fast limit locking --- When enabled, the player will be able to define a fast limit within the radar's menu, when a vehicle --- exceeds the fast limit, it will be locked into the fast box. Default setting is disabled to maintain realism -CONFIG.allow_fast_limit = true \ No newline at end of file +-- Here you can change the default values for the operator menu, do note, if any of these values are not +-- one of the options listed, the script will not work. +CONFIG.menuDefaults = +{ + -- Should the system calculate and display faster targets + -- Options: true or false + ["fastDisplay"] = true, + + -- Sensitivity for each radar mode, this changes how far the antennas will detect vehicles + -- Options: 0.2, 0.4, 0.6, 0.8, 1.0 + ["same"] = 0.6, + ["opp"] = 0.6, + + -- The volume of the audible beep + -- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 + ["beep"] = 0.6, + + -- The volume of the verbal lock confirmation + -- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 + ["voice"] = 0.6, + + -- The volume of the plate reader audio + -- Options: 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 + ["plateAudio"] = 0.6, + + -- The speed unit used in conversions + -- Options: mph or kmh + ["speedType"] = "mph" +} \ No newline at end of file