Forum rules - please read before posting.

How to "Pause" an ActionList and Resume at same point later using Script

So been working hours on this with no solution in sight. Please help.

What I want to do:
I wrote a Custom Action (Let's call this CloudCall.) which brings up a pop-up box with a button in it. Pushing that button will contact the cloud for a result. When that result returns, I want to resume the Actionlist right after that Custom Action. 

1. I know the official way is to stop the ActionList, do what I said above, and then run another Cutscene, but I don't want to call a new Cutscene every time this happens because this is a repeatable action that happens A LOT. I want to stay in the same ActionList.

2. I tried grabbing the parent actionlist using "override public void AssignParentList(ActionList actionList)" in my Custom Action, but this seems to go into some sort of infinite loop I'm not sure why.

3. Then I tried getting the parent actionlist by adding lines after the action.AssignParentList (line318) in IEnumerator RunAction in ActionList.cs. Then I would Kill (because Pause doesn't seem to work) the list, then after the cloud result returns, I would run the list again using actionlist.RunFromIndex(nodeIdxStoredEarlier). This was successful....until I started calling nested actionlists from within my main actionlist. When I use CloudCall inside my nested actionlists this messes up everything because the ActionList: Run's "Wait Until Finish?" option seems to kick in whenever the nested actionlist hits a stop, because like I said earlier, CloudCall calls Kill on the current actionlist.

So is there a better way to do CloudCall? Thanks so much!

Comments

  • Welcome to the community, @davidy13.

    You say that Pause doesn't seem to work, but haven't described in what way.  Once an ActionList has been paused, it can only be resumed by calling:

    AC.KickStarter.actionListManager.Resume (myActionList);

    However, pause/resume calls are best done externally via the ActionList: Pause or resume Action in separate lists.

    Similarly, the best way to kill an ActionList safely is to call:

    AC.KickStarter.actionListManager.EndList (myActionList);

    That said, you should be able to avoid all this by having your custom Action wait while the cloud UI is open.

    The provided ActionTemplate.cs file demonstrates how an Action can be made to wait until some point in time before continuing:

    if (!isRunning)
    {
        isRunning = true;
        return defaultPauseTime;
    }
    else
    {
        isRunning = false;
        return 0f;
    }

    This causes the Action to run twice.  During the second time, isRunning is made false, and the method returns zero - which causes the Action to stop.  You can have this run indefinitely until some other check is made with:

    if (!isRunning)
    {
        // Open cloud

        isRunning = true;
        return defaultPauseTime;
    }
    else
    {
        if (cloudIsOpen)
        {
            return defaultPauseTime;
        }

        isRunning = false;
        return 0f;
    }

    Where "cloudIsOpen" is a boolean that is true while your external cloud UI is open.  Have this default to True, and when your cloud process has completed, you can set it to False to continue the ActionList.
  • Thanks Chris! This seems to work quite well.

    However, now I've run into another problem: The mouse cursor disappears when the Action is in the infinite loop. It still seems to work, it just doesn't appear.

    I have the Cursor rendering set to Hardware, Display cursor to Always, Replace mouse cursor to false.

    How can I get my cursor back? I am on a Mac, not sure if that affects it.
  • If the ActionList itself has its When running field set to Block Gameplay, then the game will place itself in "Cutscene" mode for its duration.

    The game state can be displayed at any time via the Show 'AC status' box field at the bottom of the Settings Manager.

    You can define a "Cutscene cursor" in the Cursor Manager, but alternatively you can set the When running field to Run In Background, so that it doesn't affect the game state.  To prevent the player from interacting / moving as normal during this time, you can use the Engine: Manage systems Action to disable the Interaction and Movement systems at the start of the ActionList, and another to enable them at the end.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.