Mythruna

Modder's Workbench => Scripting => Topic started by: Michael on July 09, 2014, 11:00:43 AM



Title: Track Movement?
Post by: Michael on July 09, 2014, 11:00:43 AM
I'm curious if there is a possibility to track movement for a player, object, or any entity in general. I want to make this awesome script that will be so awesome that it's awesome. The only way that I've thought to do it is to use a Timer and compare the connection's position to the previous one, and see the difference (if there is one) but I would find that inefficient.

I haven't learned packet handling. :c


Title: Re: Track Movement?
Post by: pspeed on July 09, 2014, 12:09:56 PM
The sort of events necessary to do this easily haven't been implemented yet.  It's required by the AI stuff, though, and a few other things.

Trying to implement a heart beat event yourself will be problematic, I think.  The only thread safe way to do it (in the public release) would be to queue up a simulation SimCommand that requeues itself over and over... I think.  I don't know if the GameSimulation object is exposed to scripts or not.  Looks like from the player context getSystems().getSimulation() might do it.

I'm a little fuzzy on the old scripting.

But a Timer won't really be good because you'll potentially be doing things that aren't thread safe.


Title: Re: Track Movement?
Post by: Michael on July 09, 2014, 01:16:12 PM
The sort of events necessary to do this easily haven't been implemented yet.  It's required by the AI stuff, though, and a few other things.

Trying to implement a heart beat event yourself will be problematic, I think.  The only thread safe way to do it (in the public release) would be to queue up a simulation SimCommand that requeues itself over and over... I think.  I don't know if the GameSimulation object is exposed to scripts or not.  Looks like from the player context getSystems().getSimulation() might do it.

I'm a little fuzzy on the old scripting.

But a Timer won't really be good because you'll potentially be doing things that aren't thread safe.
Okay, thanks for the tips. I was looking around for a class that would queue itself, and be ran each loop


Title: Re: Track Movement?
Post by: pspeed on July 09, 2014, 03:08:15 PM
If you create your own SimCommand you could give it the simulation... then when it runs it can requeue itself.