(SOLVED) Setting upper limits of global variables?

Get help using Construct 2

Post » Tue Feb 18, 2014 10:47 pm

In my game, I'm making Psi's health a global variable. From the start, I want her to have some basic health and energy regeneration. How do you set the upper limits of this so a +1 health won't go higher than the variable?
Last edited by PSI on Thu Feb 27, 2014 4:55 pm, edited 1 time in total.
Image
B
20
S
4
Posts: 382
Reputation: 3,004

Post » Tue Feb 18, 2014 10:52 pm

You can use the clamp instruction.

clamp(x,low,high) will be :
low if x < low
x if low < x < high
high if high < x

You can find it in the system expressions.
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Wed Feb 26, 2014 7:43 pm

Thank you @Guizmus!
Image
B
20
S
4
Posts: 382
Reputation: 3,004

Post » Wed Feb 26, 2014 7:54 pm

I'm trying that right now but having a hard time gtting it in right. Could you be specific of how to set the global variable with it?
Image
B
20
S
4
Posts: 382
Reputation: 3,004

Post » Wed Feb 26, 2014 8:04 pm

@PSI

Here is an example. There is an heath regeneration of 1/sec, and you have buttons to add an substract heath. Events should help you see how to use this instructions.
You do not have the required permissions to view the files attached to this post.
B
17
S
8
G
4
Posts: 473
Reputation: 6,221

Post » Thu Feb 27, 2014 4:56 pm

Thank you for the example @ Guizmus!
Image
B
20
S
4
Posts: 382
Reputation: 3,004


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 21 guests