forked from MagmaMcFry/Factorissimo2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdates.lua
More file actions
112 lines (109 loc) · 3.6 KB
/
updates.lua
File metadata and controls
112 lines (109 loc) · 3.6 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Updates = {}
Updates.init = function()
global.update_version = 8
end
Updates.run = function()
if global.update_version <= 1 then
-- Remove all factory port markers because they're placed wrong
for _, factory in pairs(global.factories) do
for _, entity in pairs(factory.outside_port_markers) do entity.destroy() end
factory.outside_port_markers = {}
end
-- Issue where deconstructing factory building Mk3s would return a factory building Mk1
-- Is fixed, but we gotta give players back their lost factories
local player = game.players[1]
if player and player.valid then
for i=10,99 do
local savename = "factory-3-s" .. i
if global.saved_factories[savename] then
player.insert{name=savename, count=1} -- Insert to player 1's inventory
end
end
end
end
if global.update_version <= 2 then
-- Change fluid connection base_area to capacity
for _, tick_conns in pairs(global.connections) do
for _, conn in pairs(tick_conns) do
if conn and conn._type == "fluid" then
if conn.outside.valid then conn.outside_capacity = conn.outside.fluidbox.get_capacity(1) end
if conn.inside.valid then conn.inside_capacity = conn.inside.fluidbox.get_capacity(1) end
end
end
end
for _, factory in pairs(global.factories) do
for _, conn in pairs(factory.connections) do
if conn and conn._type == "fluid" then
if conn.outside.valid then conn.outside_capacity = conn.outside.fluidbox.get_capacity(1) end
if conn.inside.valid then conn.inside_capacity = conn.inside.fluidbox.get_capacity(1) end
end
end
end
end
if global.update_version <= 3 then
for _, factory in pairs(global.factories) do
local layout = factory.layout
if layout.name == "factory-1" then
layout.inside_size = 30
layout.outside_size = 8
elseif layout.name == "factory-2" then
layout.inside_size = 46
layout.outside_size = 12
elseif layout.name == "factory-3" then
layout.inside_size = 60
layout.outside_size = 16
else -- Some other factory, maybe someone fiddled with the mod
layout.inside_size = 30
layout.outside_size = 8
end
end
end
if global.update_version <= 4 then
-- for _,player in pairs(game.players) do
-- local gui = player.gui.top.factory_camera_placeholder
-- if gui then
-- local camera_frame = gui.factory_camera_frame
-- if camera_frame then
-- camera_frame.destroy()
-- gui.style.visible = false
-- end
-- end
-- end
end
if global.update_version <= 5 then
-- Refresh all connection markers because they may have been turned around by 0.15.10
for _, factory in pairs(global.factories) do
for _, conn in pairs(factory.connections) do
Connections.refresh_connection_indicator(conn)
end
end
end
if global.update_version <= 6 then
for _, tick_conns in pairs(global.connections) do
for _, conn in pairs(tick_conns) do
if conn and conn._type == "belt" then
if conn.from.valid then
conn.from_line_1 = conn.from.get_transport_line(1)
conn.from_line_2 = conn.from.get_transport_line(2)
end
if conn.to.valid then
conn.to_line_1 = conn.to.get_transport_line(1)
conn.to_line_2 = conn.to.get_transport_line(2)
end
end
end
end
end
if global.update_version <= 7 then
update_all_power_settings()
for _, player in pairs(game.players) do
local gui = player.gui.top.factory_camera_placeholder
if gui then gui.destroy() end
end
end
--Check that all connections are still correct given any changes other mods may have made.
for _, factory in pairs(global.factories) do
Connections.recheck_factory(factory, nil, nil)
end
global.update_version = 8
end