How to form formulas

This forum is currently in read-only mode.
From the Asset Store
About 900+ game portals: 400 e-mails, 514 contact/submit forms (last update: 2022, October, +275 contacts)
  • and well... many my previous issues are left unasweared

    Yes, they are, but isn't it much better to work on only one problem until it is solved, then go on to the next, instead of getting information overkill?

    wow. everyday i learn something new. never knew about such thing. how weird is that simitation O.o like - it can easly count 2 + 2 but have troubles with 0,2 + 0,2?

    It can, but we the bad, mean humans limitate it. We only give him a limited number of bits. But with a floating point number there are occasions where those bits are not enough to exactly represent the number, and so the processor jumps to the nearest possible representation.

    also - what the heck is int expression??? i never seen that before on both expresions and system expresions pages on wiki.

    http://sourceforge.net/apps/mediawiki/construct/index.php?title=System_Expressions

    You will find it under part 9: System

    It converts a string or a float to an integer by rounding down.

    the problem is, last frame suppose to be 100% ShieldEnergy only, just the first frame 0% should be displayed only when ShieldsCurrent hits 0%. with this the last frame 100% is for some reason never played, or should i say - it is but if ShieldCurrent is about 100% (100,000001% for example).

    The formula I wrote down is designed to show the shield status 100% only, if EnergyCurrent matches exactly EnergyTotal. On the other hand it displays the 0% frame also up until a certain amount (when using 11 frames everything below 10%)

    If you want to tweak its behavior, just replace 'int' by 'round' or 'ceil'. Ceil rounds up to the next integer, and round rounds to the nearest integer [=> round(1.49) = 1, round(1.5) = 2]

    If you use 'ceil' instead of 'int', then the 0% frame is only shown, if EnergyCurrent is exactly 0, whereas the 100% frame will be shown for every value above 90%.

    why my method doesnt work and why your does.

    Just because I have a small lead over you in programming. Just keep on doing and you will solve such problems by yourself with ease. Promised.

  • [quote:1nsm11e8]

    Yes, they are, but isn't it much better to work on only one problem until it is solved, then go on to the next, instead of getting information overkill?

    hmm. i need to agree with you but not entirely. you see my values system is all based on "set" event. for example imagine 100 shields types all called with "call function" event. and within that event the changes made by shields switching are made by "set var" event.

    now imagine later when ill type all that engines, shields, weapons, reactors ect stats and ill find out that to have a buff/boost/bonus thing i must use something else then "set var" event. and now 2-3 days spent on rewriting all the "call functions".

    its not like i want to do everything at once, its just i am a well planer aka i always try to met an dead end and be forced to go allll the way baaack.

    thats why i want to know that before ill reach the "point of no return".

    here, today i would propably use few extra variables to get the total value. like total value = valueReactor + valueBonus1 + valueUpgrade1 + valueAllYourBaseBelongToUs. but i would need to reserve a space for such variable. hmmm thinking of it... maybe ill just make that emergency variable after all? so when i change the TotalValue count so all the totalValue scatered around "Call Functions" be get auto-fixed.

    [quote:1nsm11e8]It converts a string or a float to an integer by rounding down.

    string = text and float = ?

    but... oh man. this might be beyond my capabilities. thats sound like chinese to me. its like saying it converts Er'Zuhz or a De'ruhn to an Elhe'lion by rounding down (thats dwarfish btw).

    dont get me wrong, i am not jumping at you. i just look down, with pity, at my lack of understanding asking myself that horrible question - em i really sure i want to make a game with so less near to nothing programing knowledge. at this point i cant see how i am supposed to finish my game without some 2nd dev helping me out constantly(that wasnt any kind of suggestion, just my growing depresion).

    [quote:1nsm11e8]The formula I wrote down is designed to show the shield status 100% only, if EnergyCurrent matches exactly EnergyTotal. On the other hand it displays the 0% frame also up until a certain amount (when using 11 frames everything below 10%)

    If you want to tweak its behavior, just replace 'int' by 'round' or 'ceil'. Ceil rounds up to the next integer, and round rounds to the nearest integer [=> round(1.49) = 1, round(1.5) = 2]

    If you use 'ceil' instead of 'int', then the 0% frame is only shown, if EnergyCurrent is exactly 0, whereas the 100% frame will be shown for every value above 90%.

    <img src="http://1.bp.blogspot.com/_UME67yLANIY/SvMhgOzXSEI/AAAAAAAAATw/Ay8PDdHDVAU/s320/jawdrop1236883259.jpg">

    umm, so what? hold on. so okey umm and what if i want the opposite? i mean to have 0% be drawn when value is 0-9%? (+/-) or both? like 0% only when 0% and 100% only when 100%?

    i am so sorry Tulamide, you must be feeling like talking to a rock

    [quote:1nsm11e8]Just because I have a

    HUGE

    lead over you in programming. Just keep on doing and you will solve such problems by yourself with ease. Promised.

    there, fixed. and i am more interested "why" technicaly my doesnt work.

    like - all the ranges are being set, are conditions are being met. but it still doesnt aint working.

    100% = show frame 11 (100%)

    90-99% show frame 10 (90%)

    80-89% show frame 9 (80%)

    and so on. i dont understand why the engine cant get it and is either stuck on 1st frame or the 11th totaly ignoring everything betwen. and i am asking also because - not always the % splits we'll be the same. imagine a situation when i would want/need 10% frame be drawn on 20%, 20% be drawn at 60% and 30% be drawn on 90%. thats 3 diffrent jumps and the splits arent equal. with my method (if it would be working that is) i can easly adjuct any range(s) how i please when with your (even if its working) i am stuck with equal pieces.

    and well, in most case i am uncertain will it work or not. but in this case was was 100% sure this will work. the rain started falling, ive opened my umbrella but my head still gets wet. i want to know why. where are the holes in the umbrella and how can i fix them.

    EDIT:

    oh great, it apears i cant define Variable with a sum of variables. like variable 1 = variable a + variable b. at least not from variable manager. my only idea is to set a "always" event defining that var. shame the variable manager doesnt recognise expressions though.

  • Lets look at this in a more simplified way.

    If your max shield hp is 1000, and you have 10 different states, you can use that as a percentage.

    always

    ->sprite set frame to int(shields('health')/100)

    Note:

    Frame 0 is not possible, but the system will use the closest to it frame 1.

    http://dl.dropbox.com/u/666516/framepercent.cap

    And while your looking at the system expressions take a look at lerp.

    int(lerp(1,10, Sprite.Value('hp')/1000))

  • [quote:3u0a6okv]->sprite set frame to int(shields('health')/100)

    hold on, what do you mean by shields nad health?

    i mean which is Total and which is Current? and do i need to set it for every state or like tulamide?

    sorry. i still dont quit get what int expression really is. but this is more of english language problem rather then me being math-handycaped.

  • Correct me if i'm being dumb :

    [quote:1ut1a92i]int(value)

    Convert the given string or float to an integer.

    It means you can convert the text "3" to the number 3.

    Or round the Float 3,2 to the Integer 3. (I think Tulamide said it is rounded down).

    Etc...

    You cannot convert text like 'blah blah" into a number with int. Actually, I wonder what int("blah blah") would return...

  • Yeah^

    Int() just means that you want to use an integer, or whole number.

    Not 0.5, 1.98988, but 1, 2, 3....

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Btw, is there a difference between floor(3.2654) and int(3.2654) ?

  • Actually, it's a bit more.

    numbers are rounded down to the next integer:

    int(3.2) = 3

    int(4) = 4

    int(5.892) = 5

    strings will be searched for numeric values at the beginning of the string, and the resulting number then rounded down to the next integer:

    int("20") = 20

    int("43.342") = 43

    int("51abcdefg") = 51

    int("51.56abcdefg") = 51

    ...

    and ... int("blah blah") = 0

    Btw, is there a difference between floor(3.2654) and int(3.2654) ?

    I can't really see one, because floor works exactly the same than int (edit: forgot a word) even on strings...

    Lets look at this in a more simplified way.

    If your max shield hp is 1000, and you have 10 different states, you can use that as a percentage.

    >always

    ->sprite set frame to int(shields('health')/100)

    Note:

    Frame 0 is not possible, but the system will use the closest to it frame 1.

    http://dl.dropbox.com/u/666516/framepercent.cap

    And while your looking at the system expressions take a look at lerp.

    int(lerp(1,10, Sprite.Value('hp')/1000))

    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.

  • oh! so its just another variation of "round" expresion? O.o

    so... i can use my method but i just need to add round...?

    i just dont see whats wrong with my method (aside from the obvious - that it isnt working lol).

    i mean - why? i am just like a guy who was drinking coffee and sudenly his coffee mug explode.

    i am like - What The Hell?

    also... Tulamide. for some reason frame 11 (graphical 100%) is never shown. the value must get higher then 100% like 100,6% in order for it to be show. how can this be fixed? can it? i mean - i can live on never seeing totaly empty ShielBar but never seeing Maxed bar is rather depresing and anoying. this is mostly because of that weird XX.0989987% result i am getting from the proccesor - i know. hey is there a way command to round down or up (or something) variable? the only event options i know are add substract and compare. otherwise i will be forced to follow Arima advice and pass on 0.XX values aka adjuct the whole points system by adding two more zeros to any value (so 0.01 will be now 1). but thats hell of a job and will turn any numbers into massive values (weakest game shield being 10000 instead of 100)

    and well, i still dont know any method of capping a value. beside the obvious IF ShieldsCurrent is greater then ShieldsTotal substract -0.01.

    [quote:t20jw1o1]

    This is confusing more than helping.

    totaly agree no offence of course. i just think i need to "level up" few times and ill be able to get hold on this.

    anyway. thank you VERY KINDLY. all of you. this is an extreme convo and i learn alot.

    in fact, just using/learning Construct and talking with you guys is more brain-stimulating then 5 years of my high-school had been.

    PS:

    and please note that i am NOT using you as my freeware teechers who are just waiting for me to whistle to come runing in lust of serving my needs. i respect you, you time and your imput. no one pays you for what you do, and i am aware of this.

    but laso think how constructive and informative this thread is for any newbie like me who maybe have similiar problems.

  • [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.

    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.

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

    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.

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

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

    Download: shipstatus.cap

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

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

    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.

    Download: shipstatus2.cap

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