Community Forum

Error: Event initialization only allowed at compile time

Forum Overview >> Scripting

Created28.09.2017 23:54

Tim Derks (timmiej93) 28.09.2017 23:54
After moving the code for my events to a separate file, and loading that file through 'source()', I get this error (twice, I have two different events) when I load the game. Before moving to separate files, I didn't get this error. I decided to check the Seasons mod, since I know they have their events in separate files as well, and saw that I have my files / loading set up in exactly the same way. What can be causing this error?

Tim Derks (timmiej93) 29.09.2017 11:19
My own stupid mistake, once again.
I had the source() call in a loadMap() function. Since this function is called AFTER all code has been compiled, the source() calls were also being called after compilation. This is not allowed. Simply moving the source() calls outside of any function fixed the issue.

Tim (sliv) (Unknown) 29.09.2017 15:44
Easy mistake to make, and this is still good knowledge you've posted for myself and other people trying to write lua for this game.

Note: Log in to post. Create a new account here.