Expression Editor - Minimum

JGary321JGary321 Member Posts: 1,246
edited November -1 in Tech Support
I am either really bad at understanding or this is a typo??

This is from the wiki, I would think the answer here would be 12....

min

Usage: min(x,y)

Return the smaller value of two numbers or variable values.

Example: min(12,35) = 25

Comments

  • BeyondtheTechBeyondtheTech Member Posts: 809
    Typo. Difenitely.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    That is the all-powerful MIN function! Short for Minimum.

    Use it to set a upper limit on something.

    You would use it like this:

    Let's say in your game you collect coins.
    Every time you touch a coin in the game, the game.cointTotal increases by one.
    Now let's say your wallet only holds 100 coins.

    You COULD add in a Rule that says something like:

    Rule
    When game.coinTotal < 100
    Change Attribute game.coinTotal To: game.coinTotal + 1

    Or you COULD add a Rule that says something like this

    Rule
    When game.coinTotal > 100
    Change Attribute game.coinTotal To: 100

    The MIN function allows you to simplify and get rid of that extra Rule like this:

    When Actor overlaps or collides with Actor of type Coin
    Change Attribute game.coinTotal To: min(game.coinTotal+1,100)

    The second number represents the upper limit.

    It subtle, but getting rid of any extra Rules is very important on a resource-starved device like the iPhone!

    You would use MAX in the opposite way to set a bottom limit on something.
    Like this:

    When my gun has been fired,
    Change Attribute game.ammo To: max(game.ammo-1,0)

    Hope this helps!

    Joe
  • firemaplegamesfiremaplegames Member Posts: 3,211
    oops! just reread the thread! yes, it's a typo!
  • JGary321JGary321 Member Posts: 1,246
    Hehe, yea I was gonna use it to set an upper limit like you said. Then I seen that & I was like what the heck, that's when I tried it & figured I would SMITE the Typo of Injustice. Salad eaters may not feel safe once again!

    PS: Sorry you had to do a big write-up FMG. Just sleep well knowing you wrote it in vain... err...sleep well anyways..
Sign In or Register to comment.