Get text to show first number in global variable + more

0 favourites
  • 4 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Hey guys,

    I'm using a global variable for my health, and it's max three digits. XYZ.

    I have two text boxes, once to show the health to 99 while each hundred is counted as an extra "life" or like Metroid's energy tank.

    Basically I want one text box to only show "X" for the number of 'energy tanks', while the second text box only shows "YZ" so we know how much health we have until another energy tank is "used up".


    Global variable shows 399 (HP)

    Text Box 1 shows : 3

    Text Box 2 shows : 99

    Currently I'm using three global variables, one to control the text box 1, another to control text box 2 and a third that "fills" so the game knows when to add an energy tank.

    Any idea how to do this?

  • global variable: Health = 399

    text box 1: Int(Health /100)

    text box 2: Int(Health %100)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • EyeForcz

    Thanks a lot, you're a big help!

  • Alternatively you could use some string expressions.

    text box 1: left(str(Variable1),len(str(Variable1))-2)

    text box 2: right(str(Health), 2)

    Granted, not very elegant

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