Forum rules - please read before posting.

Local variables not saving?

edited February 2018 in Technical Q&A
Hey, I've had this weird problem with local variable bools not saving when you change them.

For example in a scene, I have a local variable to check whether you've already had a certain conversation to give you info about a room, so that when you leave and come back, it doesn't pop up again.

So I have a cut scene, it checks if the bool is false, then says all the dialogue info etc, then when it's finished it sets 'haddialogue' to true. And that works. 
But when I leave the room and come back again, it switches back to false and the cutscene starts again.
This happened a few days ago with another cut scene doing the same thing but I thought it was something I did.

This used to work, but I think something is wrong because a cutscene that changed a local variable to true that I made last YEAR suddenly isn't saving anymore so the game can't progress.

If it helps, I do have an external code that sets a local variable to true in every scene, maybe it's resetting all the local variables every time it's run or something?

I'm using 1.60.4
Any suggestions? Thanks!

Comments

  • Without knowing what the code is, I can't say - please share it so we can check.

    Are any other variable types not saving either?  Are you switching between scenes using AC's Scene: Switch Action, or by custom script?

    How about the save system?  If you go to the problematic scene, save the game, set 'haddialogue' to true, and load back, does the variable revert to false?
  • edited March 2018
    Hey Chris,
    This is the code that contains the variable setting to true:
    https://i.imgur.com/t7hh7of.png
    (yes attempting to integrate photon is a bad idea but hell if i'm not trying)

    And I'm pretty sure all local variables aren't saving properly, but the global ones are fine.
    Aaand no I'm switching scenes by custom script:
    https://imgur.com/c41a084f-8114-48f3-822a-beef5234501a

    I do think it must be something to do with that. Does AC save all the local variables as you use the 'change scene' action and that's why it's not saving? Because the action is not being used and is just being switched externally?

    Perhaps there is a way around this i.e. calling the AC script that saves the local variables in my script first, and then running the rest of the script after?
  • The custom code to set the boolean value is fine, but it's almost certainly switching the scenes with custom script (though the image link is giving me a 404 error).

    When the Scene: Switch Action is called, AC will save the scene (among a few other tasks) beforehand.  This was previously necessary to use, but in the latest release it can be done through standard scripting means so long as you call the following method beforehand:

    AC.KickStarter.sceneChanger.PrepareSceneForExit ();
  • edited March 2018
    Hey Chris,
    Ah thank god you thought of making that method.
    It works now, thank you :')
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.