0 Favourites

Adding multiple variables

  • Hi Guys,

    I've had a trawl through the forum but can't seem to find an answer to my problem.

    I have 3 levels, each with its own global variable for the level score.

    When the you die / complete the game, there's a final score layout, only I'm having headaches trying to add the 3 global variables up.

    For example:

    endScore=LevelOneScore+LevelTwoScore+LevelThreeScore ?

    Any help is much appreciated, mainly to stop any more hair falling out! :D

    And a big thanks to all the posts here for teaching me so much, you look like a good bunch!

  • Forgot to add, the formula I'm looking for is the one like this:

    Scoreboard Layout...

    System | Every Tick | endScore | Set text to ""&Score+Score2+Score3

    What am I doing wrong?

  • Try this for the set text: str(int(Score) + int(Score2) + int(Score3))

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Hello Jayjay,

    Thanks for your quick response, I tried:

    str(int(Score) + int(Score2) + int(Score3))

    and

    str(int(Score)+int(Score2)+int(Score3))

    ...but it only seems to show the score from the level I was on, it doesnt add the score from previous level(s) to the end score, any ideas why?

  • I'd say you're doing the set text part right. Most likely the scores are 0 because they aren't being set properly or are being reset somewhere.

  • Hi Ramones,

    Makes sense - Jayjay's answer looks the part.

    So if I complete layout 1 (level 1) and move on to layout 2 (level 2), why isnt the global variable "Score" being remembered? On all event sheets, at the top is "reset all global variables" but I wouldnt have thought that applies when you leave it to go to a new layout? <img src="smileys/smiley23.gif" border="0" align="middle" />

    This is the first time I've done more than one level so I'm still learning!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Isometric multiple floors
74 9,717
eleanorawesome's avatar
eleanorawesome
Unread hot topic
64 12,940
trollface's avatar
trollface
Unread hot topic
46 17,522
ex32's avatar
ex32