Forum rules - please read before posting.

request: AC version of DoOnceOnly()?

edited September 2019 in Technical Q&A

Hello! So if you are familiar with AGS, there is a command called "if (DoOnceOnly())" which is incredibly useful. It essentially checks if something has been done before, and returns true or false. Would an AC equivalent be possible? Something like this: https://imgur.com/a/11TFX0o

Or does something like this exist already?

It would save a lot of time fiddling with variables! :)

Comments

  • Use the Variable: Run sequence Action and set the # of possible values field to 2. Keep Run on a loop? unchecked.

    This is effectively the same thing - the first output socket will be used when the Action is first run, and the second will be used all other times.

    To have this behaviour carry over into save games / survive scene reloads, you will need to rely on a variable by checking Save sequence value?. However, the cog icon does allow you to auto-create and assign a new variable for you.

  • edited September 2019

    Hi Chris. I tried doing this, and it works! (after I discovered I needed to generate the variable). However, it does not seem to be surviving saves/reloads. The save sequence value box is checked. Here is how mine is setup: https://imgur.com/a/fhjAml6

    I am noticing that the save/reload issue seems to be a reoccurring problem with me and I am wondering if I am doing something else wrong.

    Edit: To be clear, here is what happens. I have a trigger actionlist that I only wanted to run the first time you enter it. I used the Run Sequence command as instructed. I saved my game BEFORE I enter the trigger. I enter the trigger and the sequence runs fine. Then I reload and enter the trigger again. The sequence does NOT run. If I quit the game before reloading, the sequence runs as expected.

    If I save AFTER the sequence is triggered, and then reload, the sequence does not play. This is the expected behavior.

  • OK, this is the third time typing this response. Hopefully it sticks this time!

    I tried your suggestion and it worked! However, as with everything I do there seems to be an issue with saving and reloading. I autogenerated a variable and ticked the "save sequence variable." Here's what my command looks like: https://imgur.com/a/fhjAml6

    My goal here is to create a trigger actionlist that I only play the first time you enter it. I used your run sequence command. Here's what happens.

    1- I approach the trigger. Before I enter it, I save my game.
    2- I enter the trigger. The actionlist plays as expected.
    3- I reload my game (saved from before I entered the trigger).
    4- I enter the trigger again.
    5- The actionlist does NOT play.

    If I QUIT the game before reloading, then the actionlist plays as expected.

    If I save the game after the actionlist plays, and then reload, the actionlist does NOT play as expected.

    Thanks again!

    -Dave

  • OK, this is the third time typing this response. Hopefully it sticks this time!

    Apologies for the auto-spam-flagging. Not sure exactly why it was, but I've verified your account so it won't happen again.

    However, as with everything I do there seems to be an issue with saving and reloading

    From what the screenshot shows, all looks OK. What is the variable's actual value at each of these times? It should be zero before entering the Trigger, and 1 afterwards (and revert back to zero upon loading). If that's correct, it may be an issue with the Trigger itself - I'll attempt a recreation, but any more info about it will help.

    My goal here is to create a trigger actionlist that I only play the first time you enter it.

    If that's the actual scenario here, there's no need to rely on this method. You can simply turn off the Trigger once it's run by using the Object: Send message Action at the end of the ActionList, and sending the "Turn Off" command to the Trigger.

    This will disable the Trigger, and you can save this change in state by attaching the Remember Trigger component to it.

  • edited September 2019
    I tried doing that, but since the action list plays in the background, turning the trigger off also stops the action list from playing. And if I leave the command until the end, moving in and out of the trigger causes the actionlist to reset. As for "more info", is there anything specific that you need?
  • Huh. Apparently the solution was to actually give a name to the generated variable other than "New variable." That seems to have done the trick! :smiley:

  • since the action list plays in the background, turning the trigger off also stops the action list from playing

    That shouldn't be the case. You're specifically sending the "Turn Off" command, and not "Kill"? Though this shouldn't be necessary, it is also possible to move the Trigger's Actions into a new Cutscene, and then have the Trigger run the Cutscene with the ActionList: Run Action.

    Apparently the solution was to actually give a name to the generated variable other than "New variable."

    Odd - I wonder if simply viewing the variable was enough. Global or Local? I can't reproduce such an issue.

  • I've been thinking of putting a trigger's actions in a cutscene anyway because it will be easier to keep track of them.

    I had created a few "new variables" with the same name, which could be the cause of the conflict.

    Either way it works now! If I have any more trouble I will let you know. Thanks again!

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.