How do I make a limit for a Variable?

Get help using Construct 2

Post » Thu Oct 20, 2016 10:30 pm

I making a clicker game, and i need to know how can i make a variable limit (a variable cant have a value bellow 0.00000001) and in my clicker game, i made the following: Click in Button, If money Greater or Equal (Investment1), ADD 1 BitcoinMinerAPP, Subtract Value: Investiment1 from Money, Set Variable: Investment1*1,17 (to upgrade 17% the value). i wanna know if there is a way to the Investment1 New value dont be lower than 0.00000001 (the value have to be the nearest value possible) thanks. (note: i dont have too much experience with C2)
B
13
S
1
Posts: 58
Reputation: 701

Post » Thu Oct 20, 2016 11:01 pm

Set Value to max(0.00000001,newValue).
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438

Post » Fri Oct 21, 2016 6:53 am

create another variable with the maximum number and then make a compariton, or do that oosyrag said
B
22
S
4
G
2
Posts: 55
Reputation: 2,220

Post » Fri Oct 21, 2016 9:25 am

New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
293
S
117
G
96
Posts: 7,310
Reputation: 71,069

Post » Fri Oct 21, 2016 8:41 pm

Message: roxinhojp can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Kyatric wrote:Use the clamp() https://www.scirra.com/manual/126/system-expressions system expression.

https://dl.dropboxusercontent.com/u/36472942/construct/forumhelp/Variable_limits_clamp_clicker.capx Capx example made in r238)
Image

Ok, it worked :). but in the text (Money), it show more than 8 number (2.3312179264534545 in a test) how do i limit it to only 8 numbers?
B
13
S
1
Posts: 58
Reputation: 701

Post » Fri Oct 21, 2016 8:46 pm

As seen in the How do I FAQ :

Round and limit the number of decimals of a number - LINK
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
293
S
117
G
96
Posts: 7,310
Reputation: 71,069

Post » Sat Oct 22, 2016 10:48 pm

Message: roxinhojp can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
Kyatric wrote:As seen in the https://www.scirra.com/forum/how-do-i-frequently-asked-questions_t63692 How do I FAQ :

Round and limit the number of decimals of a number - https://www.scirra.com/forum/expression-needed-to-round-number_p1015301?#p1015301 LINK

i didnt understand, i need to make a limit for the Text box.
Example:
the variable value (Money) its = 0.72882365002341
but i want it to show ONLY 8 decimals (0.72882365)
B
13
S
1
Posts: 58
Reputation: 701

Post » Sun Oct 23, 2016 3:57 am

round(money*100000000)/100000000
Mistakes were made.
B
53
S
27
G
114
Posts: 1,695
Reputation: 64,438

Post » Sun Oct 23, 2016 3:18 pm

oosyrag wrote:round(money*100000000)/100000000

THANKS! IT WORKED! now the coin system its perfect, i will continue with the project! :D
B
13
S
1
Posts: 58
Reputation: 701


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests