diff --git a/ChoGGi's Library/Changelog.md b/ChoGGi's Library/Changelog.md index b88551dbf..dfcf29bed 100644 --- a/ChoGGi's Library/Changelog.md +++ b/ChoGGi's Library/Changelog.md @@ -1,6 +1,9 @@ ## Library Changelog ## v12.3 (Unreleased) +- Added GetCityLabels() +- > If loading pre-picard saves in picard (update not dlc) +- > Only needed during OnMsg.LoadGame - Examining certain objs wouldn't open child examine below parent examine. ## v12.2 (4 Aug 2024) diff --git a/ChoGGi's Library/Code/CSV.lua b/ChoGGi's Library/Code/CSV.lua index 48a1f2fdd..91091a256 100644 --- a/ChoGGi's Library/Code/CSV.lua +++ b/ChoGGi's Library/Code/CSV.lua @@ -103,11 +103,11 @@ do -- MapData local topography local rating = mapdata and mapdata.challenge_rating or 0 if rating <= 59 then - topography = str_RelativelyFlat + topography = str_RelativelyFlat elseif rating <= 99 then - topography = str_Rough + topography = str_Rough elseif rating <= 139 then - topography = str_Steep + topography = str_Steep end -- create item in export list diff --git a/ChoGGi's Library/Code/CommonFunctions.lua b/ChoGGi's Library/Code/CommonFunctions.lua index 5b2f2ad48..587a07a90 100644 --- a/ChoGGi's Library/Code/CommonFunctions.lua +++ b/ChoGGi's Library/Code/CommonFunctions.lua @@ -8129,6 +8129,17 @@ function ChoGGi_Funcs.Common.OpenIn3DManipulatorDlg(obj, parent) }) end +-- If loading pre-picard saves in picard (update not dlc) +-- Only needed during OnMsg.LoadGame + +-- Copied in Fix Bugs +function ChoGGi_Funcs.Common.GetCityLabels(label) + local UIColony = UIColony + local labels = UIColony and UIColony.city_labels.labels or UICity.labels + return labels[label] or empty_table +end + +-- Be removed sometime (see Examine.lua) function ChoGGi_Funcs.Common.EntitySpawner(obj, params) -- If fired from action menu diff --git a/Expanded Cheat Menu/Code/OnMsgs.lua b/Expanded Cheat Menu/Code/OnMsgs.lua index 6f352e943..00a4d7e83 100644 --- a/Expanded Cheat Menu/Code/OnMsgs.lua +++ b/Expanded Cheat Menu/Code/OnMsgs.lua @@ -1196,8 +1196,8 @@ do -- LoadGame/CityStart --~ end --~ end --~ end - local function UpdateLabelSpeed(labels, speed, cls) - local objs = labels[cls] or "" + local function UpdateLabelSpeed(speed, label) + local objs = ChoGGi_Funcs.Common.GetCityLabels(label) for i = 1, #objs do objs[i]:SetBase("move_speed", speed) end @@ -1298,36 +1298,38 @@ do -- LoadGame/CityStart end -- update existing speeds if UserSettings.SpeedColonist then - UpdateLabelSpeed(labels, UserSettings.SpeedColonist, "Colonist") + UpdateLabelSpeed(UserSettings.SpeedColonist, "Colonist") end if UserSettings.SpeedRC then - UpdateLabelSpeed(labels, UserSettings.SpeedRC, "Rover") + UpdateLabelSpeed(UserSettings.SpeedRC, "Rover") end if UserSettings.SpeedShuttle then local speed = UserSettings.SpeedShuttle - local objs = labels.CargoShuttle or "" + local objs = ChoGGi_Funcs.Common.GetCityLabels("CargoShuttle") for i = 1, #objs do objs[i]:SetBase("move_speed", speed) end end -- I figure looping through it twice is better then some complicated if else - if UserSettings.SpeedWaspDrone then - local speed = UserSettings.SpeedWaspDrone - local objs = labels.Drone or "" - for i = 1, #objs do - local obj = objs[i] - if IsKindOf(obj, "FlyingDrone") then - obj:SetBase("move_speed", speed) + if UserSettings.SpeedWaspDrone or UserSettings.SpeedDrone then + local objs = ChoGGi_Funcs.Common.GetCityLabels("Drone") + if UserSettings.SpeedWaspDrone then + local speed = UserSettings.SpeedWaspDrone + for i = 1, #objs do + local obj = objs[i] + if IsKindOf(obj, "FlyingDrone") then + obj:SetBase("move_speed", speed) + end end end - end - if UserSettings.SpeedDrone then - local speed = UserSettings.SpeedDrone - local objs = labels.Drone or "" - for i = 1, #objs do - local obj = objs[i] - if not IsKindOf(obj, "FlyingDrone") then - obj:SetBase("move_speed", speed) + + if UserSettings.SpeedDrone then + local speed = UserSettings.SpeedDrone + for i = 1, #objs do + local obj = objs[i] + if not IsKindOf(obj, "FlyingDrone") then + obj:SetBase("move_speed", speed) + end end end end @@ -1490,7 +1492,7 @@ do -- LoadGame/CityStart end -- not sure why this would be false on a dome - local domes = labels.Dome or "" + local domes = ChoGGi_Funcs.Common.GetCityLabels("Dome") for i = 1, #domes do local dome = domes[i] if dome.achievement == "FirstDome" and type(dome.connected_domes) ~= "table" then @@ -1499,7 +1501,7 @@ do -- LoadGame/CityStart end -- something messed up if storage is negative (usually setting an amount then lowering it) - local storages = labels.Storages or "" + local storages = ChoGGi_Funcs.Common.GetCityLabels("Storages") procall(function() for i = 1, #storages do local obj = storages[i] diff --git a/Mods ChoGGi/Autonomous Extractors/Code/Script.lua b/Mods ChoGGi/Autonomous Extractors/Code/Script.lua index 8eb8db8a8..d02a8fe91 100644 --- a/Mods ChoGGi/Autonomous Extractors/Code/Script.lua +++ b/Mods ChoGGi/Autonomous Extractors/Code/Script.lua @@ -39,8 +39,9 @@ local function UpdateBuildings() end -- update existing buildings - local objs = UIColony:GetCityLabels("MetalsExtractor") - table.iappend(objs, UIColony:GetCityLabels("PreciousMetalsExtractor")) + local objs = ChoGGi_Funcs.Common.GetCityLabels("MetalsExtractor") + table.iappend(objs, ChoGGi_Funcs.Common.GetCityLabels("PreciousMetalsExtractor")) + for i = 1, #objs do local obj = objs[i] diff --git a/Mods ChoGGi/Autonomous Factories/Code/Script.lua b/Mods ChoGGi/Autonomous Factories/Code/Script.lua index 11f8fbb97..0061857f0 100644 --- a/Mods ChoGGi/Autonomous Factories/Code/Script.lua +++ b/Mods ChoGGi/Autonomous Factories/Code/Script.lua @@ -60,7 +60,7 @@ local function UpdateBuildings() -- update existing buildings local objs = {} for id in pairs(mod_options) do - table.iappend(objs, UIColony:GetCityLabels(id)) + table.iappend(objs, ChoGGi_Funcs.Common.GetCityLabels(id)) end for i = 1, #objs do diff --git a/Mods ChoGGi/Build Mystery Rewards/Code/Script.lua b/Mods ChoGGi/Build Mystery Rewards/Code/Script.lua index 91c411fd4..bf97781eb 100644 --- a/Mods ChoGGi/Build Mystery Rewards/Code/Script.lua +++ b/Mods ChoGGi/Build Mystery Rewards/Code/Script.lua @@ -83,7 +83,7 @@ local function StartupCode() UIColony:SetTechResearched("Purpose of the Spheres") UIColony:SetTechResearched("Xeno-Terraforming") - local objs = UIColony:GetCityLabels("Crystals") + local objs = ChoGGi_Funcs.Common.GetCityLabels("Crystals") if #objs > 0 then local mystery = UIColony.mystery if mystery then diff --git a/Mods ChoGGi/Colonist Next Age/Code/Script.lua b/Mods ChoGGi/Colonist Next Age/Code/Script.lua index 7cbdf055b..d494982a9 100644 --- a/Mods ChoGGi/Colonist Next Age/Code/Script.lua +++ b/Mods ChoGGi/Colonist Next Age/Code/Script.lua @@ -78,4 +78,3 @@ end OnMsg.ModsReloaded = ModOptions -- Fired when Mod Options>Apply button is clicked OnMsg.ApplyModOptions = ModOptions - diff --git a/Mods ChoGGi/Deep Resources Never Run Out/Code/Script.lua b/Mods ChoGGi/Deep Resources Never Run Out/Code/Script.lua index 03893f064..1cc086ed2 100644 --- a/Mods ChoGGi/Deep Resources Never Run Out/Code/Script.lua +++ b/Mods ChoGGi/Deep Resources Never Run Out/Code/Script.lua @@ -1,5 +1,6 @@ -- See LICENSE for terms +local ChoGGi_Funcs = ChoGGi_Funcs local RetMapType = ChoGGi_Funcs.Common.RetMapType local max_resource = 500000 * const.ResourceScale @@ -76,11 +77,11 @@ MaxFillAll = function() end if UIColony then - local objs = UIColony:GetCityLabels("SubsurfaceDeposit") + local objs = ChoGGi_Funcs.Common.GetCityLabels("SubsurfaceDeposit") MaxDeposits(objs) RefillAllDeposits(objs) - objs = UIColony:GetCityLabels("TerrainDeposit") + objs = ChoGGi_Funcs.Common.GetCityLabels("TerrainDeposit") MaxDeposits(objs) RefillAllDeposits(objs) end @@ -94,8 +95,8 @@ function OnMsg.NewDay() return end - RefillAllDeposits(UIColony:GetCityLabels("SubsurfaceDeposit")) - RefillAllDeposits(UIColony:GetCityLabels("TerrainDeposit")) + RefillAllDeposits(ChoGGi_Funcs.Common.GetCityLabels("SubsurfaceDeposit")) + RefillAllDeposits(ChoGGi_Funcs.Common.GetCityLabels("TerrainDeposit")) end -- diff --git a/Mods ChoGGi/Disable Dust Storm Maintenance/Code/Script.lua b/Mods ChoGGi/Disable Dust Storm Maintenance/Code/Script.lua index a8f067e9f..22bc061ef 100644 --- a/Mods ChoGGi/Disable Dust Storm Maintenance/Code/Script.lua +++ b/Mods ChoGGi/Disable Dust Storm Maintenance/Code/Script.lua @@ -22,7 +22,7 @@ local SetBldMaintenance = ChoGGi_Funcs.Common.UpdateBuildings or function(obj, v end local function DisableMain(label, toggle) - local objs = UIColony:GetCityLabels(label) + local objs = ChoGGi_Funcs.Common.GetCityLabels(label) for i = 1, #objs do SetBldMaintenance(objs[i], toggle) end diff --git a/Mods ChoGGi/Drone Hub Range/Code/Script.lua b/Mods ChoGGi/Drone Hub Range/Code/Script.lua index f31fbbcf5..91ef9b414 100644 --- a/Mods ChoGGi/Drone Hub Range/Code/Script.lua +++ b/Mods ChoGGi/Drone Hub Range/Code/Script.lua @@ -31,7 +31,7 @@ local function SetHubRange() DroneHub.service_area_max = mod_DroneHubRange -- update existing hubs - local objs = UIColony:GetCityLabels("DroneHub") + local objs = ChoGGi_Funcs.Common.GetCityLabels("DroneHub") for i = 1, #objs do local obj = objs[i] SetPropertyProp(obj, "UIWorkRadius", "max", mod_DroneHubRange) diff --git a/Mods ChoGGi/Farm Cheats/Code/Script.lua b/Mods ChoGGi/Farm Cheats/Code/Script.lua index e8562fe48..90b914d5d 100644 --- a/Mods ChoGGi/Farm Cheats/Code/Script.lua +++ b/Mods ChoGGi/Farm Cheats/Code/Script.lua @@ -8,7 +8,7 @@ local mod_MechFarming local mod_MechPerformance local function UpdateFarms() - local objs = UIColony:GetCityLabels("Farm") + local objs = ChoGGi_Funcs.Common.GetCityLabels("Farm") for i = 1, #objs do local obj = objs[i] diff --git a/Mods ChoGGi/Fix Bugs/Code/Script.lua b/Mods ChoGGi/Fix Bugs/Code/Script.lua index 25ef0d6aa..33b148ab6 100644 --- a/Mods ChoGGi/Fix Bugs/Code/Script.lua +++ b/Mods ChoGGi/Fix Bugs/Code/Script.lua @@ -147,6 +147,13 @@ function OnMsg.ClassesPostprocess() -- end -- +-- Copied from ChoGGi_Funcs.Common.GetCityLabels() +function GetCityLabels(label) + local UIColony = UIColony + local labels = UIColony and UIColony.city_labels.labels or UICity.labels + return labels[label] or empty_table +end +-- do -- CityStart/LoadGame local function StartupCode(event) @@ -213,7 +220,7 @@ do -- CityStart/LoadGame -- Fix Shuttles Stuck Mid-Air (req has an invalid building) CreateRealTimeThread(function() Sleep(1000) - objs = UIColony:GetCityLabels("CargoShuttle") + objs = GetCityLabels("CargoShuttle") local reset_shuttles = {} local c = 0 for i = 1, #objs do @@ -307,14 +314,14 @@ do -- CityStart/LoadGame -- -- St. Elmo's Fire: Stop meteoroids from destroying sinkholes (existing saves) - objs = UIColony:GetCityLabels("Sinkhole") + objs = GetCityLabels("Sinkhole") for i = 1, #objs do objs[i].indestructible = true end -- -- Leftover transport_ticket in colonist objs (assign to residence grayed out, from Trains DLC) - objs = UIColony:GetCityLabels("Colonist") + objs = GetCityLabels("Colonist") for i = 1, #objs do local obj = objs[i] @@ -466,7 +473,7 @@ do -- CityStart/LoadGame -- -- Fix Buildings Broken Down And No Repair - objs = UIColony:GetCityLabels("Building") + objs = GetCityLabels("Building") for i = 1, #objs do local obj = objs[i] @@ -499,7 +506,7 @@ do -- CityStart/LoadGame -- -- Some colonists are allergic to doors and suffocate inside a dome with their suit still on. local GetDomeAtPoint = GetDomeAtPoint - objs = UIColony:GetCityLabels("Colonist") + objs = GetCityLabels("Colonist") for i = 1, #objs do local colonist = objs[i] -- Check if lemming is currently in a dome while wearing a suit @@ -518,7 +525,7 @@ do -- CityStart/LoadGame -- -- Fix Farm Oxygen 1 if mod_FarmOxygen then - objs = UIColony:GetCityLabels("Dome") + objs = GetCityLabels("Dome") for i = 1, #objs do local dome = objs[i] local mods = dome:GetPropertyModifiers("air_consumption") @@ -568,7 +575,7 @@ do -- CityStart/LoadGame -- -- https://forum.paradoxplaza.com/forum/index.php?threads/surviving-mars-game-freezes-when-deploying-drones-from-rc-commander-after-one-was-destroyed.1168779/ - objs = UIColony:GetCityLabels("RCRoverAndChildren") + objs = GetCityLabels("RCRoverAndChildren") for i = 1, #objs do local attached_drones = objs[i].attached_drones for j = #attached_drones, 1, -1 do @@ -590,7 +597,7 @@ do -- CityStart/LoadGame -- -- Check for transport rovers with negative amounts of resources carried. - objs = UIColony:GetCityLabels("RCTransportAndChildren") + objs = GetCityLabels("RCTransportAndChildren") for i = 1, #objs do local obj = objs[i] for j = 1, #(obj.storable_resources or "") do @@ -681,7 +688,7 @@ do -- CityStart/LoadGame local radius = 100 * guim local InvalidPos = InvalidPos() - objs = UIColony:GetCityLabels("DroneHub") + objs = GetCityLabels("DroneHub") for i = 1, #objs do table.clear(positions) @@ -1152,7 +1159,7 @@ function GetCommandCenterTransportsList(...) return ChoOrig_GetCommandCenterTransportsList(...) end - local objs = UIColony:GetCityLabels("AttackRover") + local objs = GetCityLabels("AttackRover") for i = 1, #objs do local obj = objs[i] if not obj.ChoGGi_FixedRoverNameForCCC or type(obj.name) == "userdata" then diff --git a/Mods ChoGGi/Game Rules Permanent Disasters/Code/Script.lua b/Mods ChoGGi/Game Rules Permanent Disasters/Code/Script.lua index 5dbb05a27..f1e1d916e 100644 --- a/Mods ChoGGi/Game Rules Permanent Disasters/Code/Script.lua +++ b/Mods ChoGGi/Game Rules Permanent Disasters/Code/Script.lua @@ -68,7 +68,7 @@ local function UpdateMOXIE(obj) end local function UpdateMOXIES() - local objs = UIColony:GetCityLabels("MOXIE") + local objs = ChoGGi_Funcs.Common.GetCityLabels("MOXIE") for i = 1, #objs do UpdateMOXIE(objs[i]) end diff --git a/Mods ChoGGi/Increase Ranch Storage/Code/Script.lua b/Mods ChoGGi/Increase Ranch Storage/Code/Script.lua index a02cc815a..67b852264 100644 --- a/Mods ChoGGi/Increase Ranch Storage/Code/Script.lua +++ b/Mods ChoGGi/Increase Ranch Storage/Code/Script.lua @@ -20,7 +20,7 @@ local function ProdUpdate(obj) end local function UpdateRanchesLoop(label) - local objs = UIColony:GetCityLabels(label) + local objs = ChoGGi_Funcs.Common.GetCityLabels(label) for i = 1, #objs do local obj = objs[i] --~ obj.max_storage1 = mod_StockMax