Skip to content

Commit

Permalink
Lib:
Browse files Browse the repository at this point in the history
- Added GetCityLabels()
- > If loading pre-picard saves in picard (update not dlc)
- > Only needed during OnMsg.LoadGame

[email protected]
  • Loading branch information
ChoGGi committed Sep 5, 2024
1 parent 1dacef8 commit bda6809
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 49 deletions.
3 changes: 3 additions & 0 deletions ChoGGi's Library/Changelog.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 3 additions & 3 deletions ChoGGi's Library/Code/CSV.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions ChoGGi's Library/Code/CommonFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 24 additions & 22 deletions Expanded Cheat Menu/Code/OnMsgs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand Down
5 changes: 3 additions & 2 deletions Mods ChoGGi/Autonomous Extractors/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion Mods ChoGGi/Autonomous Factories/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Mods ChoGGi/Build Mystery Rewards/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion Mods ChoGGi/Colonist Next Age/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,3 @@ end
OnMsg.ModsReloaded = ModOptions
-- Fired when Mod Options>Apply button is clicked
OnMsg.ApplyModOptions = ModOptions

9 changes: 5 additions & 4 deletions Mods ChoGGi/Deep Resources Never Run Out/Code/Script.lua
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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

--
Expand Down
2 changes: 1 addition & 1 deletion Mods ChoGGi/Disable Dust Storm Maintenance/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Mods ChoGGi/Drone Hub Range/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Mods ChoGGi/Farm Cheats/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
27 changes: 17 additions & 10 deletions Mods ChoGGi/Fix Bugs/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Mods ChoGGi/Game Rules Permanent Disasters/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Mods ChoGGi/Increase Ranch Storage/Code/Script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bda6809

Please sign in to comment.