-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.lua
172 lines (156 loc) · 4.28 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
-- Getting player and inventory information for inserting items into correct places
script.on_event(defines.events.on_cutscene_cancelled, 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
}
-- creating the presets of start items you can choose from
local kits = {}
kits["small"] = {}
kits["small"]["quickbar"] = {
{1, "transport-belt"},
{2, "underground-belt"},
{3, "splitter"},
{4, "inserter"},
{5, "medium-electric-pole"},
{6, "burner-mining-drill"},
{7, "stone-furnace"},
{10, "car"}
}
kits["small"]["items"] = {
{"iron-plate", 200},
{"copper-plate", 200},
{"iron-gear-wheel", 50},
{"transport-belt", 500},
{"splitter", 50},
{"underground-belt", 50},
{"burner-mining-drill", 20},
{"stone-furnace", 20},
{"coal", 100}
}
kits["medium"] = {}
kits["medium"]["quickbar"] = {
{1, "transport-belt"},
{2, "underground-belt"},
{3, "splitter"},
{4, "inserter"},
{5, "medium-electric-pole"},
{6, "electric-mining-drill"},
{10, "car"}
}
kits["medium"]["items"] = {
{"iron-plate", 400},
{"copper-plate", 400},
{"transport-belt", 1000},
{"underground-belt", 50},
{"splitter", 50},
{"stone-furnace", 100},
{"assembling-machine-1", 50},
{"inserter", 100},
{"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},
{"lab", 8},
{"power-armor", 1}
}
kits["medium"]["armorItems"] = {
{"fusion-reactor-equipment"},
{"personal-roboport-equipment"},
{"personal-roboport-equipment"},
{"battery-equipment"},
{"battery-equipment"}
}
kits["big"] = {}
kits["big"]["quickbar"] = {
{1, "transport-belt"},
{2, "underground-belt"},
{3, "splitter"},
{4, "inserter"},
{5, "medium-electric-pole"},
{10, "car"}
}
kits["big"]["items"] = {
{"power-armor", 1},
{"iron-plate", 400},
{"copper-plate", 400},
{"transport-belt", 1000},
{"underground-belt", 50},
{"splitter", 50},
{"steel-furnace", 50},
{"assembling-machine-2", 50},
{"inserter", 50},
{"iron-chest", 50},
{"electric-mining-drill", 50},
{"medium-electric-pole", 100},
{"big-electric-pole", 10},
{"boiler", 20},
{"steam-engine", 40},
{"offshore-pump", 1},
{"pipe-to-ground", 100},
{"pipe", 100},
{"car", 1},
{"lab", 10}
}
kits["big"]["armorItems"] = kits["medium"]["armorItems"]
kits["big"]["technologies"] = {
{"automation"}
}
-- Creating setting options and setting default option to "Medium"
local kitSetting = settings.startup["script-config-start"].value
local kit = kits[kitSetting]
if kit == nil then
kit = kits["medium"]
end
-- Setup quickbar favorites
for k,v in pairs(kit["quickbar"]) do
player.set_quick_bar_slot(v[1], v[2])
end
-- Removing stardard items
local playerInventory = player.get_main_inventory()
playerInventory.remove({name="iron-plate", count=8})
playerInventory.remove({name="burner-mining-drill", count=1})
playerInventory.remove({name="stone-furnace", count=1})
playerInventory.remove({name="wood", count=1})
-- Adding items to your inventory
for k,v in pairs(kit["items"]) do
player.insert{name = v[1], count = v[2]}
end
-- finding your armour slot but checking to see if it's there as sandbox doesn't have a armor slot
-- Also adding items into your armors grid
if kit["armorItems"] ~= nil then
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
local grid = armor.grid
for k,v in pairs(kit["armorItems"]) do
grid.put{name = v[1]}
end
break
end
end
end
end
-- Unlocking the technologie in config preset "Big"
if kit["technologies"] ~= nil then
for k,v in pairs(kit["technologies"]) do
player.force.technologies[v[1]].researched = true
end
end
end)