-
Notifications
You must be signed in to change notification settings - Fork 40
/
updates.lua
66 lines (59 loc) · 1.98 KB
/
updates.lua
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
57
58
59
60
61
62
63
64
65
66
Updates = {}
Updates.init = function()
global.update_version = 12
end
local function fix_common_issues()
for _, factory in pairs(global.factories) do
-- Fix issues when forces are deleted
if not factory.force.valid then
factory.force = game.forces["player"]
end
end
end
Updates.run = function()
fix_common_issues()
if global.update_version < 11 then
error("This save is too old to be reloaded in this version of Factorissimo2. "
.. "To run this save, you will need to load and resave this map with Factorissimo2 version 2.4.5 or 2.4.6.")
end
if global.update_version < 12 then
-- Due to an update script bug, this update may already have been applied
if #global.factories > 0 and global.factories[1].layout.overlays.nw then
-- Layout has not been updated yet, so this update has not been applied
-- Begin overlay display rework
for _, surface in pairs(game.surfaces) do
for _, e in pairs(surface.find_entities_filtered{name = "factory-overlay-controller"}) do
e.destroy()
end
end
for _, factory in pairs(global.factories) do
for _, entity in pairs(factory.outside_overlay_displays) do
if entity.valid then entity.destroy() end
end
factory.outside_overlay_displays = {}
for _, entity in pairs(factory.inside_overlay_controllers) do
if entity.valid then entity.destroy() end
end
factory.inside_overlay_controllers = nil
factory.upgrades.display = nil
factory.layout.overlays = {
inside_x = factory.layout.overlays.nw.inside_x,
inside_y = factory.layout.overlays.nw.inside_y,
outside_x = 0,
outside_y = -1,
outside_w = factory.layout.outside_size,
outside_h = factory.layout.outside_size - 2,
}
build_display_upgrade(factory)
update_overlay(factory)
end
-- End overlay display rework
-- Begin port marker rework
for _, factory in pairs(global.factories) do
factory.outside_port_markers = {}
end
-- End port marker rework
end
end
global.update_version = 12
end