Page 1 of 1

How do I write a function to do something 50% of the time?

PostPosted: Tue Nov 04, 2014 3:37 am
by winkr7
Hello;

I have a bullet that when destroyed creates either explosionOne or explosionTwo 50% of the time. I wrote a function event BulletExplodes that just creates explosionOne and it works fine. How do I write an IF(random(10)<5) type branch to do either explosionOne or explosionTwo. I don't see any way to do an if type statement inside a function.

Thanks for your time.

Re: How do I write a function to do something 50% of the tim

PostPosted: Tue Nov 04, 2014 3:40 am
by blackhornet
System:Compare two values

Re: How do I write a function to do something 50% of the tim

PostPosted: Tue Nov 04, 2014 5:00 am
by winkr7
Is this the kind of thing you mean? I can't use Else here for the other explosion.

Thanks for your help.

Re: How do I write a function to do something 50% of the tim

PostPosted: Tue Nov 04, 2014 5:49 am
by blackhornet
You've got Else at the wrong level. Click on event 16 between the minus sign and the cog - that selects the whole event, then press X. That will give you an Else for that event.

Re: How do I write a function to do something 50% of the tim

PostPosted: Tue Nov 04, 2014 11:11 pm
by winkr7
I appreciate the help--so I moved up the else but it still won't accept it.

Thanks for your time again.

Re: How do I write a function to do something 50% of the tim

PostPosted: Tue Nov 04, 2014 11:19 pm
by blackhornet
Don't move the Else up, follow my instructions. (Delete the bad Else first).

Re: How do I write a function to do something 50% of the tim

PostPosted: Tue Nov 04, 2014 11:37 pm
by winkr7
Great!!! I got it to work.

Thanks blackhornet. I forgot the X.