forked from danielmartin0/PlanetsLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata-final-fixes.lua
More file actions
56 lines (50 loc) · 2.18 KB
/
data-final-fixes.lua
File metadata and controls
56 lines (50 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
PlanetsLib.check_global_variables()
require("prototypes.override-final.science")
require("prototypes.override-final.technology-updates")
require("prototypes.override-final.enhanced-tooltips")
if mods["space-age"] then
require("prototypes.override-final.check-unexpected-positions")
require("prototypes.override-final.update-connections")
require("prototypes.override-final.set-default-weights")
local ps = require("lib.planet-str")
local planets = data.raw.planet
--Set planet string for every planet based on planet name.
for _, planet in pairs(planets) do
if planet["surface_properties"] and planet["surface_properties"]["planet-str"] == nil then --Other mods can override planet strings, this is a last-resort planet string generator.
local truncated_name = string.sub(planet.name, 1, 8) --Planet strings can only be 8 characters or less.
ps.set_planet_str(planet, truncated_name)
end
-- add a surface property that marks that the planet is freezing, entities need heating
if planet["entities_require_heating"] then
local properties = planet["surface_properties"] or {}
properties["is-freezing"] = 1
planet["surface_properties"] = properties
end
end
require("prototypes.override-final.starmap")
for _, type in pairs({ "space-location", "planet" }) do
for _, location in pairs(data.raw[type]) do
if location.sprite_only then
data.raw[type][location.name] = nil
end
end
end
local gas_list = { "oxygen", "nitrogen", "carbon-dioxide", "argon" }
local enforce_percentage = settings.startup["PlanetsLib-enforce-gas-percentage"].value --Whether code should assert that combined gas contents add up to less than 100%.
for _, planet in pairs(planets) do
if planet.surface_properties and enforce_percentage then
local gas_content = 0
for _, gas in pairs(gas_list) do
if planet.surface_properties[gas] then
gas_content = gas_content + planet.surface_properties[gas]
end
end
assert(
gas_content <= 100,
"Combined gas contents of planet "
.. planet.name
.. ' exceed 100%. To override this assertion, add \'data.raw["bool-setting"]["PlanetsLib-enforce-gas-percentage"].forced_value = false\' to settings-updates.lua.'
)
end
end
end