OnEvent(self, e)... 🤓😬
I seem to be having trouble understanding how to implement and use User defined:
- Event Handles
I feel ive looked EVERYWHERE and found wht seemed to be wonderfull examples.. Alot of which i could of copy-pasted and went on but i wont learn anything from that...
Possible Case Uses:
- Fire even when specific variables pass a threshhold.
- object method called on event...
object.on_event(self, e)e could be event object such as:
- so on ...
- fire on item add or removal
- fire on hostile within range
list can go on..
i know there is plenty of modules on PyPI but from what ive seem they seem EXTREAMLY simple to implement... for some reason im cannot grasp my head around this.
here is a couple sources i have read over:
mikael last edited by
I primarily use it to implicitly save data to file whenever it is changed, but I did have other ambitions as well.
@mikael I will look into that right now 🙃 if its ok givin its points in my direction i can add on to and pass back what what i come up with?
to be as clear as i can im looking to build event system for 2d rpg game invironment. can weither be a single Event "manager" or an Event Tree of handelers. i do know that givin this will be open world with World spread events. i.e.
- World boss spawns
- random action quest events
- rescource spawn timers
so it must be cental to World environment and not Player. i want to have events handle all the updat callbacks instead ofboriginal idea of piggy backing off scene event loop. only reason i say this is, so far, what ive read up on states that to do much of what im "requiring" ill have to use Asynch and thats way too much blocking of main too often. so i figured i would have tiers of timers. kind of like layers, that each will handel a specific "section" of events..
- player data update (position, attributes, buff/debuff, ect...)
- mob, resource, loot and ither World Spawn timers
- world actions( repeatingbquests, traveling merchants...)
- interactions( combat start, finish/ zone enter, ect...)
like i mentioned in OP i know i can go to PyPI and just install a module and 30 min later it works for the most part but id like to build at least 1/2 of the structure myself. this way
- i understand whats going on in my program
- i have more control of whats going on especially since im demanding so much event driven aspevts from python.. i read somewhere that python isnt really geared for my use case
hopfully this gives enough information to draw a picture ill be more than happy to provide anything needed..
mikael last edited by
@stephen, well, complicated stuff.
tinysync can give you the building block of reacting to object or data structure changes (synchronously).
As another building block, you could look at scripter, which you can use to write different types of logics which run on the loop. Scrpter supports running different scripts at different update intervals, which could be used to spread the load according to your hierarchy.
Combining the two, tinysync can trigger async scripter scripts.
Awesome thanks! ill look into this combonation. i would of never thought of using scripter 😅
if i manage to get a stable system going ill post. save nextguy this heartache