The greatest hits of character feedback (Read 193161 times)

Started by PotS, May 22, 2009, 11:49:10 pm
Share this topic:
Re: The greatest hits of character feedback
#101  August 27, 2015, 03:52:33 pm
  • ******

cond() works similar to ifelse() in that it takes an expression, evaluates it, and then returns the value of the expression in the 2nd or 3rd parameter depending on whether the first expression (parameter #1) is true or false respectively.

ifelse(life=lifemax, 1.0, 0.5)
cond(life=lifemax, 1.0, 0.5)
are logically equivalent and will return "1.0" as the value if your character is at max life.

The difference is that ifelse() will evaluate all expressions and cond() will not. For example:
ifelse(numhelper(30), helper(30),pos x, 0)
will actually cause debug flood if helper(30) doesn't exist. Why? Because with ifelse(), numhelper(30), helper(30),pos x, and "0" are all evaluated and then the result is of the final expression is returned. Using the same expressions with cond() will look like this:
cond(numhelper(30), helper(30),pos x, 0)
This will return the same result without the potential for debug flood. First numhelper(30) is evaluated. If it's true, only then will "helper(30),pos x" be evaluated and its result returned. If "numhelper(30)" is false, ie. "0," then "helper(30),pos x" won't ever be seen.

cond() is most synonymous to a ternary expression in actual programming and scripting languages, such as JavaScript and PHP. ifelse() is just a broken mess. I hope that helps to clear up any confusion you had about it, but I'm curious as to how you're trying to use it that it's crashing mugen.

Using IfElse, MUGEN will evaluate the entire code - both "true" and "false" statements.

Using Cond, MUGEN will ONLY evaluate one statement.

As far as I can tell, there is no reason to ever use IfElse... Cond works exactly the same, but prevents errors.

MUGEN will report errors if the code it is evaluating is invalid.  Such as, if you use a trigger redirection to a non-existent player.


IfElse(PlayerIDExist(60),(PlayerID(60),Pos X - 100),ScreenPos X + 100))
If there is not a Player with ID 60, this will result in an error because the "false" code (PlayerID(60),Pos X - 100) is still being evaluated, even though it is not being triggered.

Cond(PlayerIDExist(60),(PlayerID(60),Pos X - 100),ScreenPos X + 100))
If the condition is "false" (there is not a Player with ID 60), the "true" code is completely ignored and is not evaluated - there will be no error.
Re: The greatest hits of character feedback
#102  September 19, 2015, 11:19:35 pm
  • ****
  • Frankenspriting is fun!!
    • Peru
So I know this is a pretty old thread, but since it's stickied I figured no harm done in asking here?

Anyway, just one small doubt I have about head and waist positions: If I scale a character, should I type in the end result coordinates or the default pre-scale coordinates? Like, say my character's head.pos by default is at -10,-100, but I scale him down to 0.8. Do I still type in -10,-100 or -8.-80?
Millie, "Ozy and Millie" said:
"I think there are really three types of people: "Glass is half-full" sorts of people, "Glass is half-empty" sorts of people,
and people who will spit into the glass until that's fixed."
Re: The greatest hits of character feedback
New #103  October 01, 2017, 07:46:01 am
  • ******
  • Loyal to the Game
    • USA

  • Online
Wasn't sure where to post this but I'll post it here as a lesson to all. This is probably explained in the docs but regardless, I want to make this clear to everyone.

trigger1 = e|| (var(5)  := var(5)&1023)

Is not the same as this:
trigger1 = e|| (var(5)  := (var(5)&1023))

In the first instance, you're setting var(5) to itself, then taking the bitwise AND of the first 10 bits. This means you're setting var(5) to itself and essentially doing nothing. In the second instance, you're setting var(5) to the first 10 bits of var(5), like you were probably trying to do like I was.

This order of operations goes for any bitwise operand, including OR and XOR.

Do not make this mistake that I made.