Question about global variables?

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • So I wanted to set a global variable that was the previous layout. Saved as a string. Set the var as a string=current.layout name. However, as an action, I can't change the string value to the current layout name.

    Doing it as a numerical value works, but strings don't work. I'm sure there is a reason for this, but I'm not sure why.

    It's ok, I can map all the levels to numbers, but I struggled with not being able to say layout = "Town"

    Also go to previous layout isn't workable in this situation. Otherwise, I would use that.

    I guess the question is why strings can be global vars but can't be changed from the event sheets...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Not sure what went wrong here but you definitely can set the string in general. Are you trying to use 'current.layoutname' specifically because you just need 'layoutname'. Is the variable of type string? If it's number it would produced NaN as a result you can see this in debug view.

    Or possibly it is to do with how your event sheets are linked, it may not be reading the event at all or running it (though if you say a number worked then maybe it is running it). You can also share the file if you need further help.

  • Yes. I guess I didn't understand that global vars still need to be linked via the event sheets. I had moved all my globals into one sheet and when I included that on the layout it let me use a string. Dumb, Dumb, sigh.

    Thanks

  • The globals can remain in one sheet so it must be a different problem. The events that modify the globals need to be on an event sheet linked(included) to the layout you are on.

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)