Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random help

Status
Not open for further replies.

un1k

Technical User
Mar 8, 2004
30
CA
Hi there, I am having trouble with the Random in Director, I am trying to play at a random time, a sound. Here's my code.


on startMovie
global startTicks
set startTicks = the ticks
end startMovie

on idle
global startTicks
set ticksElapsed = the ticks - startTicks
if (ticksElapsed > 3*100) then
randomAnimation
end if
end idle

on randomAnimation

puppetsound 8,"Police Radio Chatter 0"&random

end


****
I have 8 sound call "Police Radio Chatter 01" to 08


Any help would be very appreciated, thank you.
 
Are u trying to play a sound at a random time?
From what i've seen, your script only plays at a fixed interval.
Here's a script that i think may help:

------------------------------------
global soundList
global myTimer

on startMovie
soundList = ["1","2","3"]
randomAnimation
end
on prepareFrame
if the timer > myTimer then
the timer = 0
randomAnimation
end if
end
on randomAnimation
myTimer = random(100) + 100
soundToPlay = soundList[random(soundList.count)]
puppetsound 8,"Police Radio Chatter 0"&soundToPlay
end
------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top