forked from Pasukaru/factorio-quick-start
-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.lua
207 lines (195 loc) · 5.06 KB
/
control.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
script.on_event(defines.events.on_player_created, function(event)
local player = game.players[event.player_index]
local inventories = {
defines.inventory.player_armor,
defines.inventory.player_main,
defines.inventory.player_quickbar,
defines.inventory.player_guns,
defines.inventory.player_ammo,
defines.inventory.player_tools,
defines.inventory.player_vehicle,
defines.inventory.player_player_trash
}
-- Setup kit presets
local kits = {}
kits["small"] = {}
kits["small"]["quickbar"] = {
{1, "transport-belt"},
{2, "underground-belt"},
{3, "splitter"},
{4, "inserter"},
{5, "medium-electric-pole"},
{6, "deconstruction-planner"},
{10, "car"}
}
kits["small"]["items"] = {
{"steel-axe", 10},
{"iron-plate", 192},
{"copper-plate", 200},
{"iron-gear-wheel", 50},
{"transport-belt", 500},
{"splitter", 50},
{"underground-belt", 50},
{"burner-mining-drill", 20},
{"coal", 100}
}
kits["medium"] = {}
kits["medium"]["quickbar"] = {
{1, "transport-belt"},
{2, "underground-belt"},
{3, "splitter"},
{4, "inserter"},
{5, "medium-electric-pole"},
{6, "deconstruction-planner"},
{10, "car"}
}
kits["medium"]["items"] = {
{"steel-axe", 10},
{"iron-plate", 592},
{"copper-plate", 400},
{"iron-gear-wheel", 200},
{"electronic-circuit", 200},
{"transport-belt", 1100},
{"underground-belt", 50},
{"splitter", 50},
{"stone-furnace", 100},
{"assembling-machine-1", 20},
{"inserter", 300},
{"long-handed-inserter", 50},
{"steel-chest", 50},
{"electric-mining-drill", 50},
{"medium-electric-pole", 200},
{"boiler", 10},
{"steam-engine", 20},
{"offshore-pump", 1},
{"pipe-to-ground", 50},
{"pipe", 50},
{"car", 1},
{"coal", 200},
{"construction-robot", 50},
{"lab", 10},
{"deconstruction-planner", 1},
{"power-armor", 1}
}
kits["medium"]["armorItems"] = {
{"fusion-reactor-equipment"},
{"personal-roboport-equipment"},
{"personal-roboport-equipment"},
{"personal-roboport-equipment"},
{"personal-roboport-equipment"},
{"personal-roboport-equipment"},
{"battery-equipment"},
{"battery-equipment"},
{"battery-equipment"}
}
kits["big"] = {}
kits["big"]["quickbar"] = {
{1, "transport-belt"},
{2, "underground-belt"},
{3, "splitter"},
{4, "inserter"},
{5, "medium-electric-pole"},
{6, "deconstruction-planner"},
{10, "car"}
}
kits["big"]["items"] = {
{"power-armor", 1},
{"steel-axe", 10},
{"iron-plate", 592},
{"copper-plate", 400},
{"iron-gear-wheel", 200},
{"electronic-circuit", 200},
{"advanced-circuit", 200},
{"transport-belt", 1500},
{"underground-belt", 50},
{"splitter", 50},
{"steel-furnace", 100},
{"assembling-machine-2", 100},
{"inserter", 300},
{"long-handed-inserter", 50},
{"steel-chest", 50},
{"electric-mining-drill", 50},
{"medium-electric-pole", 400},
{"big-electric-pole", 100},
{"logistic-chest-requester", 100},
{"logistic-chest-passive-provider", 100},
{"boiler", 20},
{"steam-engine", 40},
{"offshore-pump", 10},
{"pipe-to-ground", 100},
{"pipe", 100},
{"chemical-plant", 20},
{"oil-refinery", 10},
{"car", 1},
{"coal", 50},
{"roboport", 20},
{"construction-robot", 50},
{"logistic-robot", 300},
{"lab", 10},
{"deconstruction-planner", 1}
}
kits["big"]["armorItems"] = kits["medium"]["armorItems"]
kits["big"]["technologies"] = {
{"automation"},
{"steel-processing"},
{"automation-2"},
{"oil-processing"},
{"plastics"},
{"advanced-electronics"},
{"sulfur-processing"},
{"battery"},
{"electronics"},
{"engine"},
{"electric-engine"},
{"flying"},
{"robotics"},
{"logistic-robotics"},
{"construction-robotics"},
{"logistic-system"}
}
local kitSetting = settings.startup["quick-start-kit"].value
local kit = kits[kitSetting]
if kit == nil then
kit = kits["medium"]
end
-- Find quickbar (usually player_quickbar, but god_quickbar in sandbox mode)
local quickbar = player.get_inventory(defines.inventory.player_quickbar)
if quickbar ~= nil and not quickbar.can_set_filter(1, "transport-belt") then
quickbar = player.get_inventory(defines.inventory.god_quickbar)
end
-- Setup quickbar favorites
if quickbar ~= nil and quickbar.can_set_filter(1, "transport-belt") ~= nil then
quickbar.clear()
for k,v in pairs(kit["quickbar"]) do
quickbar.set_filter(v[1], v[2])
end
end
-- Add items
for k,v in pairs(kit["items"]) do
player.insert{name = v[1], count = v[2]}
end
if kit["armorItems"] ~= nil then
-- Find armor in one of the inventories
-- Usually ends up in the armor slot. But that one does not exist in sandbox mode
for k,v in pairs(inventories) do
local inventory = player.get_inventory(v)
if inventory ~= nil then
local armor = inventory.find_item_stack("power-armor")
if armor ~= nil then
-- Add items to armor grid
local grid = armor.grid
for k,v in pairs(kit["armorItems"]) do
grid.put{name = v[1]}
end
break
end
end
end
end
-- Unlock technologies
if kit["technologies"] ~= nil then
for k,v in pairs(kit["technologies"]) do
player.force.technologies[v[1]].researched = true
end
end
end)