Page 1 of 1

Runing Random functions?

PostPosted: Mon Mar 04, 2013 1:45 pm
by bat78
Hmmm.. i was wondering all the time is it possible and if is then how to make an specific actor to run function in random time.
It is like % of running the function each 2 seconds or random selecting the time to run the function 1 - 10 seconds idk..
So.. is it possible?

Re: Runing Random functions?

PostPosted: Mon Mar 04, 2013 7:42 pm
by skydereign
You can use gE's random timer to do this, or just use random.
Code: Select all
if(floor(rand(30))==0) // <-runs 1/30 the time
{
    function();
}

If it is in draw, then that would trigger 30 times per second.

Re: Runing Random functions?

PostPosted: Mon Mar 04, 2013 7:47 pm
by bat78
Hey btw :D
so it should be in draw.. I see it work.. i can't get used to that script.. it is lil different from my main Pawn C++ :cry: sorry for the silly threat.

Re: Runing Random functions?

PostPosted: Mon Mar 04, 2013 7:49 pm
by skydereign
bat78 wrote:so it shouldn't be in draw?

Just curious, why would you say this? In general it actually would be better to use random timers, instead of draw (or use consistent timers, using that code). You said you wanted this to happen all the time though, so the use of draw seemed appropriate.

Re: Runing Random functions?

PostPosted: Mon Mar 04, 2013 7:51 pm
by bat78
Yea, i am lil bad at English and i had to think a bit of it.. but i edited it already. yours code work fine enough in draw. (+1)