YesNoOk
avatar

Ifelse help (Read 2028 times)

Started by Dope, August 27, 2012, 09:02:19 am
Share this topic:
Ifelse help
#1  August 27, 2012, 09:02:19 am
  • ****
    • thedopehouse.webs.com/
I know how to use ifelse in it's basic form but I'm still not quite sure how to properly use ifelse for more advanced situations. My character has 2 super moves, one allows rapid basic attacks and the other grants super armor. What I'm trying to do is make it so the basic attacks don't give P1 power if either of the variables for these super moves are active.

So right now I setup the basic hitdefs' getpower like this:
getpower = ifelse(parent,var(37) = 0,50,0),ifelse(parent,var(37) = 0,35,0)

this makes it so the getpower is 50,35 when rapid attack super (var 37) isn't active, and makes the getpower 0,0 when var 37 is active. That works great. My problem is I'd like it to also not getpower if var 35 is active but I'm inexperienced with making an ifelse like that so I'm clueless on how to write it.
Re: Ifelse help
#2  August 27, 2012, 09:11:16 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
in ugly form. ifelse(!var(37) || !var(35), 50,0) etc etc.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: Ifelse help
#3  August 27, 2012, 09:21:20 am
  • ****
    • thedopehouse.webs.com/
I failed to mention that this particular hitdef is a helper so I need to add parent in there otherwise it doesn't do anything. so how exactly would I add parent to what you wrote? I tried ifelse(parent,!var(37) || parent,!var(35), 50,0) but mugen didn't accept that.
Re: Ifelse help
#4  August 27, 2012, 09:49:30 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
Should be OK, don't think !parent, var(37) is correct syntax. You may want to alter your spacing.

Otherwise just go with the = 0 format.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: Ifelse help
#5  August 27, 2012, 10:02:00 am
  • ****
    • thedopehouse.webs.com/
Well the very first thing I tried was ifelse(parent,var(37)=0 || parent,var(35)=0,50,0) and when I tested it out it was still giving 50 when either var 35 or 37 were active, where as this ifelse(parent,var(37) = 0,50,0) works flawlessly and gives 0 if var 37 is active but of course that one doesn't make any mention of var(35) so it'll give 50 if var(35) is active. And I didn't mention this before but I guess I may as well now but vars 35 and 37 can't be activated at the same time, not really important but just thought I'd throw that out there anyways.

and I tried ifelse(!parent, var(37) || !parent, var(35),50,0) just for the hell of it. It doesn't crash mugen but it still gives 50 if either var 35 or 37 are active.
Last Edit: August 27, 2012, 10:06:33 am by Dope
Re: Ifelse help
#6  August 27, 2012, 11:09:25 am
  • avatar
  • ******
    • Thailand
!parent,var is correct syntax.
Re: Ifelse help
#7  August 27, 2012, 04:26:37 pm
  • *****
  • Thanks and God bless
    • USA
    • ricepigeon.neocities.org
so in other words, if either var(37) or var(35) is nonzero, then it should get 0 power correct? Then...

in ugly form. ifelse(!var(37) || !var(35), 50,0) etc etc.

...shouldn't it be && in that case, not ||?

!Var(37)=0 || !Var(35)=0 >> true
!Var(37)=1 || !Var(35)=0 >> true
!Var(37)=1 || !Var(35)=1 >> false
!Var(37)=0 || !Var(35)=1 >> tue
Last Edit: August 27, 2012, 04:30:12 pm by RicePigeon
Re: Ifelse help
#8  August 27, 2012, 07:37:11 pm
  • ****
    • thedopehouse.webs.com/
&& instead of || works perfectly, thanks RicePigeon. Although it sounds odd to me having it like this: ifelse(!parent,var(37) && !parent,var(35),50,0) sounds like if both vars 37 and 35 are active at the same time then give 0 power but I guess not because it works when either one is active (and both can't be activated at once).

2OS

Re: Ifelse help
#9  August 28, 2012, 12:41:10 am
  • ****
  • 608 Wannabe
  • Ich schicke dich zur HOELLE!! STIRB DU FEIGLING!!
    • Egypt
again for some reason i hate ifelse with numbers.

boolean algebra is better imo because it's less common and it looks and is simpler ( uses less characters ).


ifelse(!(parent,var(35)&&parent,var(37)),0,50),ifelse(!(parent,var(35)&&parent,var(37)),0,35)

50*(!(parent,var(35)&&parent,var(37))),35*(!(parent,var(35)&&parent,var(37)))


see?


if the condition in the parenthesis is true it's ""1"" so it's *1 which is 50. if it's false it's ""0"" so it's *0 which is 0.
Re: Ifelse help
#10  August 28, 2012, 12:57:45 am
  • ****
    • thedopehouse.webs.com/
huh, that's an interesting way of doing it. I totally understand it. That may come in handy for me in the future, thanks.