call up certain handlers randomly
do call random

At 20:29 10.09.98 EDT, Sarah Ashwell  wrote:
>i am writing the lingo for a child's game and i need to be able to call up
>certain handlers randomly
>if i have runTrex, chaseTrex, and hideCat as the members of my random list,
> how do i do that? i tried looking in the archives but random referred mostly
>to numbers and words & memberNums...

Two possible ways here:

execute the handlers via do or via call. DO is slower but more flexible, ie. 
you can execute lingo on the fly.

call is faster, looks better and is low fat, however, you have to supply the 
name of the script the handlers live in, too.


on randomHandlerSelect1
  -- this one is via DO
  set handlerList = ["runTrex", "chaseTrex", "hideCat", "alert " & QUOTE & "about to format your HD. May I continue?" & QUOTE]
  set Cnt = Count(handlerList)
  set cmd = getat(handlerList,Random(cnt))
  do cmd


on randomHandlerSelect2
  -- this one is via CALL, assumes there is a #script member named "testScript"
  -- where all the handlers live in.
  -- won't as easy as do does

  set handlerList = [#runTrex, #chaseTrex, #hideCat, #uglyAlert]
  set Cnt = Count(handlerList)
  set cmd = getat(handlerList,Random(cnt))
  call(cmd, script "testScript")

Home shock + cgi Bits 'n pieces Director Lingo Shocklets Contact