set N= random(some number, some number)
repeat N times.
also if you have that set just in event - it will repeat infinitely. (each tick N times) - you have to add some condition that will evaluate when that happens. you can call a function on that random number generation. example
set N = random(x,y)
call function repeat (n)
on function 'repeat'
repeat func.param(0) times
- something to do..
what i'm tryin' to say is that if you don't have that green arrow -> on your event, and no conditions that will stop that event, it will run each tick. the point of making game is that you reduce as much as you can events without green arrow "->". why? because they run each tick and you don't want that. if you want to reduce their time of execution design your game to worth with triggers (events that HAVE "->" green arrow), or use Functions that are called when something happens (usually on triggers).
here's a good example:
let's imagine you have a BALL, a guiLife (some life bar that represents objects health), and object. they have variables damage (ball), and health (guiLife and object).
bad way to do things:
- object.health < guiLife.health
- set guiLife.health = object.Health
- set guiLife.Width = guiLife.health
and now if you repeat something like this - your object takes some damage and you do this:
- on ball collision with object
- repeat (ball.damage) times
-object.health = object. health - 1
that's just horrible and performance crippling way to do things. why? when some ball hits your object it repeats the calculation, so that health from object is reduced by that damage but 1 by 1 damage.
what's the point? the first part is executing the check if objects health is lower then guiLife variable is. it happens each tick. and then executes the code behind if it is true. and what happens if let's say a ball hits your object? let's say it does 10 damage. the upper code repeats 10 times, and ball collision happens only 1.
so how can you fix that to be better performing? use a function.
-on ball collision with object - call bla with parameter ball.damage
on funcion bla
- repeat (func.param(0) ) times
- object.health = object. health - 1
subevent -object.health < guiLife.health
- set guiLife.health = object.Health
- set guiLife.Width = guiLife.health
so what's the difference? well - this only happens ONCE. no checking for difference each tick, nothing. when your ball hits object it will call function that will do the rest. you can throw a wait in there and other stuff to give it different change time, but still way better then when set on each tick. also - when repeat finishes - with function - it's done. when not done with function it will keep checking.
shit my posts are too long and unfriendly xD