Crea
Expand Your World
Create and share new mods to expand your worlds: items, monsters, skills, races, realms, game systems. Anything and everything is possible.
Learn More
Heptalon 2 Jul, 2016 @ 6:13am
Problem with the event system
I tried to get some damage modifications to work using the event system. While playing around with the system I noticed that the execution order of the listeners is verry important in some cases.

I could not find a way to change the execution order of multiple listeners on the same event inside the code. The only ways of changing the execution order I found, were renaming the mod or or changing the registration order. Both solutions are somehow limited.

Did I miss something or is there nothing like priorities or something similar?
< >
Showing 1-4 of 4 comments
Baxter900 4 2 Jul, 2016 @ 9:58pm 
Not quite sure what you mean by "execution order" in terms of events. The way the event system works is as follows:

An event is created, many of these are created in the engine (game.events[]) but you can also create your own from within python using the Event class.

Event listeners and their handlers are assigned. These are functions which will be called whenever the event is invoked. Note that handlers (aka the functions called by an event) can take arguments. Normally this is done during registration.py

Events are invoked. This triggers all handlers listening to a single event and give them the variable passed (assuming they accept variables). Off the top of my head I think you can only pass one variable when invoking events, but just use a tuple to get around that. Events are invoked all throughout the code depending on the circumstance.

Event listeners are removed. Some events will naturally be destroyed in this case this isn't needed but others would persist between game sessions (for example, if you load a game, close it, then load another without ever closing the game itself). In this case we have to set some events to remove their listeners when closing out the game.


Hope this helps you understand how events work. The execution order of events has to do with when the event is invoked.
Heptalon 3 Jul, 2016 @ 4:01am 
Thank you for the explanation. But I did not mean the execution order of the events. I want to change the execution order of multiple handlers that are assigned to one event.
Baxter900 4 3 Jul, 2016 @ 8:00am 
The events aren't designed to allow the execution order for handlers of a single event to be changed. If you're using your own event then I'd recommend making multiple events which cascade into eachother. If you're trying to do something with the internal events and to insert some code somewhere then it probably depends on what exactly you're trying to do. You could probably use a coremod though.
Heptalon 3 Jul, 2016 @ 11:29am 
Thanks, thats exactly what I wanted to know.
< >
Showing 1-4 of 4 comments
Per page: 1530 50