-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcontrol.lua
More file actions
63 lines (59 loc) · 2.49 KB
/
control.lua
File metadata and controls
63 lines (59 loc) · 2.49 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
-- require('util')
require('control.robot-recall')
require('control.robot-redistribute')
-- require('')
script.on_init(function(event)
global.teleportQueue = {}
global.teleportQueueEntryCount = 0
global.hasChanged = false
global.openedGUIPlayers = {}
global.deploying = {}
end)
script.on_configuration_changed(function(event)
if (event.mod_changes and event.mod_changes['robot-recall']) then
local old_ver = event.mod_changes['robot-recall'].old_version
if (old_ver) then
if (old_ver == "0.2.0" or string.find(old_ver, "0.1.")) then
global.teleportQueue = {}
global.teleportQueueEntryCount = 0
end
if (old_ver == "0.2.0" or old_ver == "0.2.1") then
global.deploying = {}
for _, surface in pairs(game.surfaces) do
local deploymentstations =
surface.find_entities_filtered(
{name = "robot-redistribute-chest"})
for k, v in pairs(deploymentstations) do
global.deploying[v.unit_number] =
{ent = v, deploying = false}
end
end
end
if (new_ver == "0.2.1" or
new_ver == "0.2.2" or
new_ver == "0.2.3" or
string.find(old_ver, "0.1.")) then
local newTeleportQueue = {}
for k,e in pairs(global.teleportQueue) do
local newEl = e
if (newEl.source and newEl.source.valid) then
newEl.srcPos = newEl.source.position
newEl.surface = newEl.source.surface
end
if (newEl.destination and newEl.destination.valid) then
newEl.surface = newEl.destination.surface
newEl.destPos = newEl.destination.position
end
table.insert(newTeleportQueue, newEl)
end
global.teleportQueue = newTeleportQueue
global.teleportQueueEntryCount = table_size(newTeleportQueue)
end
end
end
global.deploying = global.deploying or {}
global.teleportQueue = global.teleportQueue or {}
global.teleportQueueEntryCount = global.teleportQueueEntryCount or 0
global.hasChanged = global.hasChanged or false
global.openedGUIPlayers = global.openedGUIPlayers or {}
end)