

I think most people that are writing scripts are under the impression if you register a callback type event at any time, then it fires until you unregister it or until you exit the game, which the above example shows it definitely is not the case.īasically some of the vanilla CoC scripts don't work properly after changing settings or in certain situations until exiting the game and loading again, the above limitation is some of the reason for this. You can try different things instead of a key press eg: trigger by dialogue action, menu option, etc, the results are the same.Īnything registered outside of the "on_game_start" will be dropped on a level change unless re-registered. The above example demonstrates exactly what I'm mentioning. You can press the numpad 1 key again, check the console, yep key_press loops are spamming again, change level, key press callbacks have stopped again. The key press registered loops have been dropped altogether.ĥ. Close console and travel to another level, open the console and you can see see spamming every 2 secs:

Close console, press Numpad 1, Open console and you can see spamming every 2 secs.Ĥ. Open console and you can see spamming every 2 secs (# = time_global):ģ. RegisterScriptCallback("on_key_press", key_press)Ģ. RegisterScriptCallback("actor_on_update",on_game_start_actor_on_update_loop)ĪddUniqueCall(on_game_start_AddUniqueCall_loop)ĬreateTimeEvent("works_fine","on_game_start_CreateTimeEvent_loop",2,on_game_start_CreateTimeEvent_loop) RegisterScriptCallback("actor_on_update",key_press_actor_on_update_loop)ĪddUniqueCall(key_press_AddUniqueCall_loop)ĬreateTimeEvent("broken","key_press_CreateTimeEvent_loop",2,key_press_CreateTimeEvent_loop) Printf("key_press_CreateTimeEvent_loop: %s", time_global()) ResetTimeEvent("broken","key_press_CreateTimeEvent_loop",2) Local function key_press_CreateTimeEvent_loop() Printf("key_press_AddUniqueCall_loop: %s", tg) Local function key_press_AddUniqueCall_loop() Printf("key_press_actor_on_update_loop: %s", tg) Local function key_press_actor_on_update_loop() Printf("on_game_start_CreateTimeEvent_loop: %s", time_global()) ResetTimeEvent("works_fine","on_game_start_CreateTimeEvent_loop",2) Local function on_game_start_CreateTimeEvent_loop()

Printf("on_game_start_AddUniqueCall_loop: %s", tg) Local function on_game_start_AddUniqueCall_loop() Printf("on_game_start_actor_on_update_loop: %s", tg) Local function on_game_start_actor_on_update_loop()
