- Joined
- Feb 15, 2016
- Messages
- 9
Let me preface here first what I'm trying to achieve.
I am making an advanced command system for a map of mine, and I use vJass's .evaluate() feature to run command callbacks (which in turn use function intefaces).
It looks something like this:
I make it possible to chain commands in a single chat message, something like the following:
I'm trying to add a simple "wait" command, which will put the current command execution on hold, but there are some issues that spring to my mind.
First off, as far as I know, TriggerExecute starts a separate thread and yields when the called function either stops, returns, or calls TriggerSleepAction. So if I call TriggerSleepAction within a TriggerExecuteFunc, the next command will run instantly, because the calling thread resumes immediately, despite the command callback not having finished.
I read somewhere that TriggerEvaluate blocks the calling thread until the underlying function returns, on the other hand, but I've also read that TriggerEvaluate doesn't play nice with TriggerSleepAction.
Can someone more experienced than me shed some light on this, please? I haven't tested this thoroughly, but I'm asking since there may be a lot of subtle caveats (like in so many other places in JASS) that I might miss and be unaware of until they become an issue.
Some other, slightly unrelated questions, while I'm on the topic:
What is the real difference between TriggerEvaluate and TriggerExecute, in terms of thread starting/thread blockage, if we put aside the various performance concerns (this isn't used in a performance-heavy context, so it doesn't really matter)?
I've also stumbled across an odd native, namely TriggerExecuteWait. Does anyone know how it is different from TriggerExecute? It seems that it has something to do with TriggerSleepAction, but it's not clear to me what exactly.
P.S. I'll probably just add a dirty workaround to make "wait" work like it should, but I was wondering if it is possible to block the calling thread from within a TriggerEvaluate/TriggerExecute using TriggerSleepAction.
I am making an advanced command system for a map of mine, and I use vJass's .evaluate() feature to run command callbacks (which in turn use function intefaces).
It looks something like this:
JASS:
callbacks[commands[StringHash(command)]].evaluate(runner, as);
Code:
cmd1 arg1 arg2 arg3 | cmd2 arg1 | cmd3 arg1 arg2
First off, as far as I know, TriggerExecute starts a separate thread and yields when the called function either stops, returns, or calls TriggerSleepAction. So if I call TriggerSleepAction within a TriggerExecuteFunc, the next command will run instantly, because the calling thread resumes immediately, despite the command callback not having finished.
I read somewhere that TriggerEvaluate blocks the calling thread until the underlying function returns, on the other hand, but I've also read that TriggerEvaluate doesn't play nice with TriggerSleepAction.
Can someone more experienced than me shed some light on this, please? I haven't tested this thoroughly, but I'm asking since there may be a lot of subtle caveats (like in so many other places in JASS) that I might miss and be unaware of until they become an issue.
Some other, slightly unrelated questions, while I'm on the topic:
What is the real difference between TriggerEvaluate and TriggerExecute, in terms of thread starting/thread blockage, if we put aside the various performance concerns (this isn't used in a performance-heavy context, so it doesn't really matter)?
I've also stumbled across an odd native, namely TriggerExecuteWait. Does anyone know how it is different from TriggerExecute? It seems that it has something to do with TriggerSleepAction, but it's not clear to me what exactly.
P.S. I'll probably just add a dirty workaround to make "wait" work like it should, but I was wondering if it is possible to block the calling thread from within a TriggerEvaluate/TriggerExecute using TriggerSleepAction.