@@ -2,7 +2,7 @@ require "defines"
22
33Harpa = {}
44
5- function Harpa .register ( entity , player_idx )
5+ function Harpa .setup ( )
66 if not global .harpa_list then
77 global .harpa_list = {}
88 end
@@ -18,7 +18,10 @@ function Harpa.register(entity, player_idx)
1818 if not global .harpa_overlays then
1919 global .harpa_overlays = {}
2020 end
21+ end
2122
23+ function Harpa .register (entity , player_idx )
24+ Harpa .setup ()
2225 if Harpa .is_powered (entity , nil ) then
2326 if player_idx then
2427 Harpa .create_overlay (entity , player_idx )
139142function Harpa .tick ()
140143 if global .harpa_list then
141144 if not global .idle_harpa_list then global .idle_harpa_list = {} end
142-
145+ Harpa . setup ()
143146 Harpa .update_overlays ()
144147
145148 -- check idle emitters less often
@@ -209,6 +212,7 @@ function Harpa.update_power_armor()
209212 for i = 1 , # game .players do
210213 local player = game .players [i ]
211214 if Harpa .has_micro_emitter (player ) and not Harpa .is_idle (player , 20 ) then
215+ Harpa .setup ()
212216 table.insert (global .micro_harpa_players , player )
213217 end
214218 end
@@ -217,6 +221,7 @@ function Harpa.update_power_armor()
217221 for i = # global .micro_harpa_players , 1 , - 1 do
218222 local player = global .micro_harpa_players [i ]
219223 if Harpa .has_micro_emitter (player ) then
224+ Harpa .setup ()
220225 Harpa .tick_emitter (player , 16 )
221226 else
222227 table.remove (global .micro_harpa_players , i )
@@ -319,12 +324,14 @@ function Harpa.tick_emitter(entity, radius)
319324end
320325
321326function Harpa .ignore_biter (entity )
322- for i = # global .biter_ignore_list , 1 , - 1 do
323- local biter_data = global .biter_ignore_list [i ]
324- if not biter_data .biter .valid or game .tick > biter_data .until_tick then
325- table.remove (global .biter_ignore_list , i )
326- elseif biter_data .biter == entity then
327- return true
327+ if global .biter_ignore_list then
328+ for i = # global .biter_ignore_list , 1 , - 1 do
329+ local biter_data = global .biter_ignore_list [i ]
330+ if not biter_data .biter .valid or game .tick > biter_data .until_tick then
331+ table.remove (global .biter_ignore_list , i )
332+ elseif biter_data .biter == entity then
333+ return true
334+ end
328335 end
329336 end
330337 return false
0 commit comments