From c5bf28ca3314e0cf20537646c37455349195f5b1 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 11 Mar 2021 16:20:02 +0000 Subject: [PATCH] feat: add function to restore backed up data --- cl_radar.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cl_radar.lua b/cl_radar.lua index b5fdffa..cab124e 100644 --- a/cl_radar.lua +++ b/cl_radar.lua @@ -396,6 +396,34 @@ function RADAR:LoadDataFromDriver( data ) end ) end +-- Restores the local player's operator menu and antenna data +function RADAR:RestoreFromBackup() + -- Get the operator menu data + local omData = self:GetBackupOMData() + + -- Restore the operator menu data + if ( omData ~= nil ) then + self:SetOMTableData( omData ) + + -- Clear the backup + self:SetBackupOMData( nil ) + end + + -- Iterate through the antennas and restore their backups + for _, ant in UTIL:Values( { "front", "rear" } ) do + -- Get the antenna backup data + local antData = self:GetBackupAntennaData( ant ) + + -- Restore the antenna data + if ( antData ~= nil ) then + self:SetAntennaTableData( ant, data[ant] ) + + -- Clear the backup + self:SetBackupAntennaData( ant, nil ) + end + end +end + --[[---------------------------------------------------------------------------------- Radar essentials functions