Can someone explain how to set up if ... then situations in combination with a generated random number? For instance - if random(100)>50 then place an object on the screen or go to the next frame - or whatever.
Can someone explain how to set up if ... then situations in combination with a generated random number? For instance - if random(100)>50 then place an object on the screen or go to the next frame - or whatever.
You will need to use the system object called Special (which looks like two screens), and then do "Compare two general values"
You will then get the expression evaluator where you will be able to test the two values
Jason
im generating the random number - if its <50 i want to subtract 1 from a counter - then stop. the problem is it KEEPS subtracting 1 from the counter without stopping.












You could try adding the special condition "only one action when event loops".
.:::.Joshtek.:::.
does anyone know of a tutorial on the use of the expression editor?












Press F1 for the electronic help documentation. Under Contents go to The editors->The Expression editor.Originally Posted by delusan
Alternatively, turn to page 59 of the printed user manual.
.:::.Joshtek.:::.
Yeah, of course. If you only have one event that compares if a random number between 0 and 99 is lower than 50, that event will happen during every event loop, just like an "always" condition does. You must add an additional condition that restricts when the event runs. What do you want to use to trigger this event? You can always use "run this event once".im generating the random number - if its <50 i want to subtract 1 from a counter - then stop. the problem is it KEEPS subtracting 1 from the counter without stopping.
To me, it doesn't sound like that will work though. After all, the first condition will not always be true.You could try adding the special condition "only one action when event loops".
Your problem is probally that you want to have a single random number generated at a time and if this number is greater then a number of your choice then you perform a certain action.
having "random(100)" in a compare two vaules event will cause a different random number to be generated each time the event is ran.
You should generate a random number in a different event (like when the user clicks a button for instance) and then store this number in a variable (A counter) so that you can use the value of the counter in the comparison instead (That way the random number will stay the same).
Of course having the comparison remain true will cause the event to continue to run. So what you need to do is add code that will cause the event to become false when what you wanted to do is done. I normally do this using flags...
Which method to use depends on the case I guess. Sometimes I guess it's better to just go like:having "random(100)" in a compare two vaules event will cause a different random number to be generated each time the event is ran.
* User press Space Bar
+ random(2)=1
...to "maybe" trigger an action when the player press Space Bar.
Yes but the cases for that are rare becuase then you can't use that value anymore... If you store it then you can use it in other comparisons and calculations.