Hi, Euclid.
Thank you so much for reply and clarification. Sure, I need to explain my goal in more detail.
I'm playing with X4F scripting and implementing jumps for a certain ship (a quite specific ship with unique jump ability, that can be taken via a sub-story). The major problem is how to implement the jump process. I'm implementing it not as a separate order that can be called manually. Instead, I wish to implement it as a subprocess of generic movement implemented by the "move.generic" AI script. For that, I injected into the "move.generic" two conditional immediate calls of external AI script that does all the things. I prefer to keep all advanced functionality in external scripts and don't modify basic scripts too much.
By my idea, the initiated jump is an
"unbreakable" process, so implementation via the "move.generic" raises a problem: the "move.generic" script can be aborted or interrupted. In this case, the entire stack of running child scripts is also aborted or interrupted and, finally, it breaks the jump. It is not what I need. Therefore I wish to implement jump via critical order which can't be aborted, canceled or interrupted. The jump script is guaranteed to be done in the defined time so it is safe to run it as a critical order.
The jump script itself performs some post-processing checks and should report the result to the caller (e.g. destination object was destroyed and the jump hasn't been done). So, when I create a critical order, the order will run and interrupt the caller. After the critical order is done - the caller resumes and has to process the result from the jump order. I thought of using ship blackboard to save the result but it is not safe because there are cases when the caller can be aborted before the jump order is done and won't clean the temporarily stored jump result.
Now Implemented returning of result from the critical jump order via callback with <signal_object>. E.g., in the jump caller:
Code: Select all
<create_order ... immediate="true" comment="critical jump order">
order params
</create_order>
<wait exact="timeout">
<interrupt>
<condition>
<event_object_signalled object="this.ship" param="signal"/>
</condition>
<actions>
... handle the callback from jump order ...
</actions>
</interrupt>
</wait>
The delayed callback In the Jump order:
Code: Select all
<signal_objects object="this.ship" param="signal" param2="<jump_result>" delay="small delay" comment="a small delay is required"/>
<returm/>
It works. Even if the caller is aborted - the jump will done and the jump result will just gone because the signal won't be processed. It is OK. Though it looks ... too cumbrous. So, I'm looking for a more elegant implementation (or at least ideas about that)... Perhaps, there is a way to run a child script as a "critical" script?
Best regards.