forked from PreLeyZero/248K
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrol.lua
More file actions
200 lines (160 loc) · 5.14 KB
/
control.lua
File metadata and controls
200 lines (160 loc) · 5.14 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
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
require('scripts/electronic/el_ki_script')
require('scripts/bk_main')
require('scripts/gravitation/gr_black_hole_script')
local gui = require('scripts/gui')
local gr_gui = require('scripts/gravitation/gui')
--informatron
require('scripts/informatron/inf_main')
--===================================================================================================================
-- other functions
--===================================================================================================================
function print_start_message()
if settings.startup['overhaul_mode'].value == false then
game.print({"inf_248k.standalone_mode_msg_1"}, {r=0.5, g=0, b=0.5})
game.print({"inf_248k.standalone_mode_msg_2"}, {r=0.5, g=0, b=0.5})
elseif settings.startup['overhaul_mode'].value == true then
game.print({"inf_248k.overhaul_mode_msg_1"}, {r=0.5, g=0, b=0.5})
game.print({"inf_248k.overhaul_mode_msg_2"}, {r=0.5, g=0, b=0.5})
end
end
--===================================================================================================================
-- Event handlers
--===================================================================================================================
--init
script.on_init(
function(e)
el_ki_init(e)
gr_black_hole_init(e)
if game.active_mods["Booktorio"] then
registerThread_248k()
end
for i,v in pairs(game.players) do
gui.add_top_gui(game.players[i])
end
print_start_message()
end
)
--===================================================================================================================
--on player creation
script.on_event({
defines.events.on_player_created
},
function(e)
gui.add_top_gui(game.get_player(e["player_index"]))
if not global.message_printed then
print_start_message()
global.message_printed = true
end
end
)
--===================================================================================================================
--on built
script.on_event({
defines.events.on_built_entity,
defines.events.on_robot_built_entity,
defines.events.script_raised_built,
defines.events.script_raised_revive,
--defines.events.on_entity_cloned
},
function(e)
el_ki_on_built(e)
gr_black_hole_on_built(e)
end
)
--===================================================================================================================
--on remove
script.on_event({
defines.events.on_entity_died,
defines.events.on_pre_player_mined_item,
defines.events.on_robot_pre_mined,
defines.events.script_raised_destroy
},
function(e)
el_ki_on_remove(e)
gr_black_hole_on_remove(e)
end
)
--===================================================================================================================
--on tick
script.on_nth_tick(60,
function(e)
el_ki_buffer1_working()
el_ki_buffer1_update()
el_ki_buffer2_working()
el_ki_buffer2_update()
el_ki_core_working()
el_ki_core_update()
el_ki_supported_adder()
if global.ki.dirty then
--game.print("f")
el_ki_beacon_update()
gui.update_main()
global.ki.dirty = false
end
if global.black_hole.dirty then
gr_gui.update_main()
global.black_hole.dirty = false
end
gr_gui.update_main()
end
)
script.on_nth_tick(30,
function(e)
black_hole_base_update()
end
)
--===================================================================================================================
script.on_event({
defines.events.on_gui_click,
defines.events.on_gui_text_changed
},
function(e)
gui.on_change(e)
gr_gui.on_change(e)
end
)
script.on_event({
defines.events.on_player_selected_area
},
gui.on_selected
)
script.on_event({
defines.events.on_gui_opened,
defines.events.on_gui_closed
},
function(e)
if e["entity"] then
if e["entity"].name == "el_ki_core_entity" then
gui.add_core_gui(e,false)
end
if e["entity"].name == "fi_ki_core_entity" then
gui.add_buffer1_gui(e,false)
end
if e["entity"].name == "fu_ki_core_entity" then
gui.add_buffer2_gui(e,false)
end
if e["entity"].name == "gr_black_hole_base_entity" then
gr_gui.add_black_hole_gui(e,false)
end
end
end
)
script.on_event({
defines.events.on_research_finished
},
function(e)
if e.research and (e.research.name == "fu_ki_plus_1_tech" or e.research.name == "fu_ki_plus_2_tech") then
if not global.ki then global.ki = {} end
global.ki.dirty = true
end
end
)
--===================================================================================================================
--config change
script.on_configuration_changed(
function()
if game.active_mods["Booktorio"] then
registerThread_248k()
end
end
)