@@ -274,19 +274,18 @@ if py.stage == "data" then
274274 }
275275end
276276
277- local data_message_sent = false
278- local control_message_sent = false
279277local control_globals_outside_of_events = false
280278if py .stage == " control" then
281- py .on_event (defines .events .on_tick , function (_ )
282- --- @diagnostic disable-next-line : undefined-field
283- if not data_message_sent and prototypes .mod_data [" py-undocumented-globals" ].get (" exist" ) then
284- game .print (" [color=255,0,0]found references to undefined globals in data stage, check logs[/color]" )
285- data_message_sent = true
286- end
287- if not control_message_sent and control_globals_outside_of_events then
288- game .print (" [color=255,0,0]found references to undefined globals in control stage, check logs[/color]" )
289- control_message_sent = true
279+ py .on_event (py .events .on_init (), function (changes --[[ @as ConfigurationChangedData --]] )
280+ -- We only run if it's a new map or startup change
281+ if not changes or changes .new_version or changes .migration_applied or changes .mod_startup_settings_changed or table_size (changes .mod_changes ) > 0 then
282+ --- @diagnostic disable-next-line : undefined-field
283+ if prototypes .mod_data [" py-undocumented-globals" ].get (" exist" ) then
284+ game .print (" [color=255,0,0]found references to undefined globals in data stage, check logs[/color]" )
285+ end
286+ if control_globals_outside_of_events then
287+ game .print (" [color=255,0,0]found references to undefined globals in control stage, check logs[/color]" )
288+ end
290289 end
291290 end )
292291end
0 commit comments