timmiej93 Posted April 16, 2020 Report Share Posted April 16, 2020 So let's be honest, the "PushAction..." system used by EM4 isn't great, but it's what we've got, so I'd like to understand it a bit better. I think most scripters know what ACTION_NEWLIST and ACTION_APPEND do. ACTION_INSERTAFTERFIRST, ACTION_INSERTBEFORELAST and ACTION_REPLACEFIRST are self-explanatory, but what does ACTION_INSERT do? Where does the command get inserted? Has anyone ever figured this out? Quote Link to comment Share on other sites More sharing options...
itchboy Posted April 18, 2020 Report Share Posted April 18, 2020 In scripting, all Em4 "actors" (meaning objects, persons, vehicles) follow a sequential "list" of actions. ACTION_NEWLIST is what you indicate on any push action to start a new "list" of actions. This will override any other action at the time. ACTION_APPEND is how you continue the list. Say, you want to do task A first, then B. You would put task A as an ACTION_NEWLIST, then the next action and so on will be ACTION_APPEND. ACTION_INSERT is used to insert an action in between a set of ACTION_APPEND lines. The other ones are self-explanatory. The action will either be before the last, after the first, or replace the first action in the list. Quote Link to comment Share on other sites More sharing options...
timmiej93 Posted April 19, 2020 Author Report Share Posted April 19, 2020 Thanks for the reply. I got to about the same understanding as what you've written up, but like I asked in my initial post: Where does the command get inserted? Is there any logic to that? Quote Link to comment Share on other sites More sharing options...
Chris07 Posted April 21, 2020 Report Share Posted April 21, 2020 I guess there’s only one way to find out! Time to experiment! Quote Link to comment Share on other sites More sharing options...
itchboy Posted April 22, 2020 Report Share Posted April 22, 2020 On 4/19/2020 at 10:56 PM, timmiej93 said: Thanks for the reply. I got to about the same understanding as what you've written up, but like I asked in my initial post: Where does the command get inserted? Is there any logic to that? It gets inserted based on the order it is on the list. Newlist is always first on a pushAction list. After this, an insert or append may follow depending on what you're doing. If you put the insert after the NEWLIST, then it will actually swap places with the newlist and do the "insert" action first. This is only required in some very specific situations however, like you have a command that has separate instructions for a specific unit. Quote Link to comment Share on other sites More sharing options...
timmiej93 Posted May 1, 2020 Author Report Share Posted May 1, 2020 Alright, I finally got around to doing an experiment, after a lot of irritation. Here's the testing and the results: Calling function: blabla... Caller->PushActionExecuteCommand(ACTION_NEWLIST, "TimTest", NULL, 0, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 19, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 20, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 21, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 22, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 23, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 24, false); } }; object TimTest : CommandScript { TimTest() {} bool CheckPossible() { return true; } bool CheckTarget() { return true; } void PushActions(GameObject *Caller, Actor *Target, int childID) { System::Log("childID %i", childID); if (childID != 0) { return; } Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 1, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 2, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 3, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 4, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 5, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 6, false); Caller->PushActionExecuteCommand(ACTION_INSERT, "TimTest", NULL, 7, false); Caller->PushActionExecuteCommand(ACTION_INSERT, "TimTest", NULL, 8, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 9, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 10, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 11, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 12, false); Caller->PushActionExecuteCommand(ACTION_INSERTBEFORELAST, "TimTest", NULL, 13, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 14, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 15, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 16, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 17, false); Caller->PushActionExecuteCommand(ACTION_APPEND, "TimTest", NULL, 18, false); } }; Results in log: !childID 0 !childID 8 !childID 7 !childID 19 !childID 20 !childID 21 !childID 22 !childID 23 !childID 24 !childID 1 !childID 2 !childID 3 !childID 4 !childID 5 !childID 6 !childID 9 !childID 10 !childID 11 !childID 13 !childID 12 !childID 14 !childID 15 !childID 16 !childID 17 !childID 18 My conclusions from this test: Any PushAction... that's INSIDE another function called by PushActionExecuteCommand gets executed AFTER EVERYTHING from the calling function has been executed, as demonstrated by the numbers 0 > 19 > 20 > 21 > 22 > 23 > 24 before going to 1. Using ACTION_NEWLIST inside the second function (TimTest in this case) DOES cancel all queued commands from the calling function. For example, for the PushActionExecuteCommand with ChildID 1, if that had ACTION_NEWLIST instead of ACTION_APPEND, ChildID 8, 7, 19, 20, 21, 22, 23 and 24 do NOT print. Using ACTION_INSERT inserts the command IMMEDIATELY after the PushActionExecuteCommand that called the function you're now in. Using ACTION_INSERT again will do the same, thus pushing the previously inserted item down one spot, as demonstrated by ChildID 0 > 8 > 7. Hopefully this can prevent some frustration among scripters. If you have any questions about my testing, feel free to ask. Quote Link to comment Share on other sites More sharing options...