playMaker

Author Topic: Swapping variables in an action  (Read 1223 times)

ARK1391

  • Playmaker Newbie
  • *
  • Posts: 2
Swapping variables in an action
« on: February 12, 2018, 09:03:41 PM »
Does anyone know if there is a way to swap a float variable in an action based on which one you need to use?

I'm trying to save the final score of a puzzle between 2 scenes. In the main game the puzzles spawn into the same scene (that way we could cut down on the number of scenes in our game).

But I can't seem to find a way to change which float variable I'm saving in easy save so I can reflect that score when the player reopens the game. The issue is every puzzle is referencing the same global variable so they all end up with the same score no matter what, I need a way to change the variable being saved based on which puzzle they are doing.

Any help would be greatly appreciated!!

tcmeric

  • Beta Group
  • Hero Member
  • *
  • Posts: 768
Re: Swapping variables in an action
« Reply #1 on: February 12, 2018, 11:32:42 PM »
Hi, you cannot change the variable being saved, but you can use can change the value of the variable.

Eg,

float finalScore.
float levelOneScore
float levelTwoScore.

If level one, then.
finalScore = levelOneScore.

Then save finalScore

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Swapping variables in an action
« Reply #2 on: February 13, 2018, 01:55:32 AM »
Hi.
You could also use an array for your scores.

Element 0 = score level 1
Element 1 = score level 1
and so on. (an array starts at 0 btw)

Then you can load the array and make a loop to total the saved scores in the list (array) to get the total score