# How to form formulas

### » Wed Nov 24, 2010 10:33 pm

[quote:21s5xrmq]This is confusing more than helping. Please have a look at my long post about it. There are two variables that are related to each other and influence each other. Also, my expression never reaches frame 0, I think it is a better way to make sure you don't get unwanted values instead of hoping that Construct will catch the error. [/quote:21s5xrmq]

What ever.
Still say it's a better way. He just needs to get the value of the variable before he even thinks about setting the frame.
Then there's the lerp method. You can use 1-10, 1-11, 5-20, and change the modifier to n*0.1.
And if your terribly worried about returning a zero, all you have to do is change the always condition to a comparison making sure its greater than 0.
B
178
S
50
G
205
Posts: 8,684
Reputation: 127,211

### » Thu Nov 25, 2010 4:55 am

[quote="newt":38u77i3y]
What ever.
Still say it's a better way. He just needs to get the value of the variable before he even thinks about setting the frame.
Then there's the lerp method. You can use 1-10, 1-11, 5-20, and change the modifier to n*0.1.
And if your terribly worried about returning a zero, all you have to do is change the always condition to a comparison making sure its greater than 0.[/quote:38u77i3y]
I'm not concerned about lerp, but that we are not talking about one variable, but two. The 'health' value, as you called it, is not a fixed percentage. It is related to another value and both change during gameplay. health = 500 means 100% only if the second value is 500. If it is 800 then health = 500 means 62.5%. And that's not covered by your proposal.
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,289

### » Thu Nov 25, 2010 7:44 am

Look at it this way. Regardless of what makes up the formula, it will always have a total.
He can figure that amount on the fly, and save it to a separate variable.
B
178
S
50
G
205
Posts: 8,684
Reputation: 127,211

### » Thu Nov 25, 2010 5:44 pm

I know it and you know it, newt, but irbis doesn't. In fact, that's why he asked for help. I still think omitting one of the key probs is not helping, but confusing more.

Anyway, I've made a cap with a nice 11-frame status display and editboxes to play around with different values for 'total' and 'current' while running the app. You will see how simple and yet versatile the formula is.

B
24
S
8
G
10
Posts: 1,821
Reputation: 8,289

### » Thu Nov 25, 2010 7:18 pm

okey now i want to cut myself...
in your cap, you have 11 frames, and i have 11 frames. in your all frames are correctly displayed coresponding to values. in my, max value frame is like only displayed when Current is higher then Total. the only diffrence is that your cap doesnt have the auto regeneration and doesnt uses decimal values.

and yes i know i am stubborn but i still havent learned why my method doesnt work when basing on logic it should work.
B
29
S
8
G
7
Posts: 643
Reputation: 6,482

### » Thu Nov 25, 2010 8:52 pm

[quote="irbis":2ls23oew]okey now i want to cut myself...
in your cap, you have 11 frames, and i have 11 frames. in your all frames are correctly displayed coresponding to values. in my, max value frame is like only displayed when Current is higher then Total. the only diffrence is that your cap doesnt have the auto regeneration and doesnt uses decimal values.

and yes i know i am stubborn but i still havent learned why my method doesnt work when basing on logic it should work.[/quote:2ls23oew]
Without seeing your cap I can't exactly tell where the problem is. Here is another cap, this time not editable, but the shield regenerates slowly over time and mean meteoroids hit the ship occasionally, substracting from the shield's current value. And all of this with crooked floating numbers, like 678.542 for total or 29.943 for the regeneration value.

Compare this cap to yours and find the differences, then you will learn why your method doesn't work.

B
24
S
8
G
10
Posts: 1,821
Reputation: 8,289

Previous