Sign in to follow this  
Followers 0
Vindicator209

Random()

5 posts in this topic

Well, heres a small bit of my script:

$talk = 1
$talk1 = 1
$talk2= 2
$talk3 = 3
$timertalk = 1000
While 1
If $talk = 1 Then
    $talktimer=TimerInit()
    $talk = 0
EndIf
If TimerDiff($talktimer) = 1000 Then
$ran= Random(10,30)
$ran = Round($ran,-1)
    If $ran = 10 Then
    Send($talk1)
EndIf
    If $ran = 20 Then
    Send($talk2)
EndIf
    If $ran = 30 Then
    Send($talk3)
EndIf
$talk = 1
EndIf
WEnd

now, it doesnt send anything, I figure its something wrong with Random(), I couldnt use Random(1,3,1) because it kept returning 0 so I put Random(10,30) and then rounded it to -1 to return it to the closest 10...but how come it wont work?


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites



I've found that there has to be a further difference between minimum and maximum to make it an int (1,5,1), I would use Round(Random(1,3))

Hope that helps...

Share this post


Link to post
Share on other sites

hmm, still doesnt send, but I'm wondering weatther its a problem with the timer or random, but I just cant figure it out...


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

ok , figures, the random works, its a problem with the timer...


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

sorry for 3rd post***

I figured it out! The loop doesnt loop around fast enough to chech the timer at exactly 1000, so TimerDiff() < 1000 works fine

Thanks for help on the random too, works actually better then wht I had =D


[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0