Get text to show first number in global variable + more

Get help using Construct 2

Post » Sat Jan 31, 2015 7:07 am

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".

Example,

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?
The moderators are corrupt and ban for no reason, especially that condescending neckbeard asshole Kyatric. The forums are filled with fanboys.
Banned User
B
22
S
7
G
1
Posts: 558
Reputation: 2,925

Post » Sat Jan 31, 2015 7:27 am

global variable: Health = 399

text box 1: Int(Health /100)
text box 2: Int(Health %100)
Read this:
yeah, i really like to say that you should "Read this:"
B
12
S
5
Posts: 138
Reputation: 1,490

Post » Sat Jan 31, 2015 11:03 am

@EyeForcz

Thanks a lot, you're a big help!
The moderators are corrupt and ban for no reason, especially that condescending neckbeard asshole Kyatric. The forums are filled with fanboys.
Banned User
B
22
S
7
G
1
Posts: 558
Reputation: 2,925

Post » Sat Jan 31, 2015 11:26 am

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 :D
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786


Return to How do I....?

Who is online

Users browsing this forum: David181, OBLIVION and 59 guests