And here's another version of the code that Buzz just posted.  It's a 
little more efficient because  generates the random list in one pass 
using only a single list:

on scrambleText oldStr
   list1 = []
   -- create a sequence of scrambled numbers
   n = oldStr.char.count
   repeat with i = 1 to n
     addAt(list1, random(i), i)
   end repeat

   -- re-order the original characters
   -- according to the order created above
   newStr = ""
   repeat with i = 1 to n
     newStr = newStr & oldStr.char[list1[i]]
   end repeat
   return newStr
end

Enjoy,

Irv

At 9:43 AM -0700 10/1/02, Buzz Kettles wrote:
>At 8:53 AM -0500 10/1/02, you wrote:
>>I do have Gary's "lingo for games" book.  Nothing in there.  I do know
>>how to do a crossword thanks to him though.
>>
>>What I want is the user sees...
>>
>>Rdwo and has to then type in the answer...word.
>>I have several of these to do so I'd like to have something somewhat
>>universal.
>
>here's a movie handler that gets sent a string & returns a scrambled 
>version of the same string
>
>on scrambleText oldStr
>   list1 = []
>   -- create a sequence of numbers
>   n = oldStr.char.count
>   repeat with i = 1 to n
>     list1[i] = i
>   end repeat
>   -- scramble them
>   list2 = []
>   repeat with i = 1 to n
>     k = list1.count
>     pick = random(k)
>     list2.append(list1[pick])
>     list1.deleteAt(pick)
>   end repeat
>   -- re-order the original characters
>   -- according to the order created above
>   newStr = ""
>   repeat with i = 1 to n
>     newStr = newStr & oldStr.char[list2[i]]
>   end repeat
>   return newStr
>end
>
>hth
>
>-Buzz
>
>>
>>-----Original Message-----
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED]] On Behalf Of Howdy-Tzi
>>Sent: Monday, September 30, 2002 2:38 PM
>>To: [EMAIL PROTECTED]
>>Subject: Re: <lingo-l> Word scramble game
>>
>>
>>On Monday, September 30, 2002, at 02:05 PM, Sharon Moeller wrote:
>>
>>>  Can anybody point me to a tutorial for a word scramble type of 
>>>game.  I have to do a bunch of them and I am looking for a 
>>>universal script
>>>  to get them all done quickly.
>>
>>mediamacros.com might be worth a try.
>>
>>What do you mean by "word scramble"? Individual letters? Actual words?
>>
>>
>>               Warren Ockrassa | http://www.nightwares.com/
>>   Director help | Free files | Sample chapters | Freelance | Consulting
>>         Author | Director 8.5 Shockwave Studio: A Beginner's Guide
>>                     Published by Osborne/McGraw-Hill
>>         http://shop.osborne.com/cgi-bin/osborne/0072195622.html
>>
>>[To remove yourself from this list, or to change to digest mode, go to
>>http://www.penworks.com/lingo-l.cgi  To post messages to the list, email
>>[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]).
>>Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>>
>>[To remove yourself from this list, or to change to digest mode, go 
>>to http://www.penworks.com/lingo-l.cgi  To post messages to the 
>>list, email [EMAIL PROTECTED]  (Problems, email 
>>[EMAIL PROTECTED]). Lingo-L is for learning and helping with 
>>programming Lingo.  Thanks!]
>
>[To remove yourself from this list, or to change to digest mode, go 
>to http://www.penworks.com/lingo-l.cgi  To post messages to the 
>list, email [EMAIL PROTECTED]  (Problems, email 
>[EMAIL PROTECTED]). Lingo-L is for learning and helping with 
>programming Lingo.  Thanks!]


-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to