You are here: Home → Forum Home → The Mac Observer Forums → Design & Create → Thread
Having trouble with simple word game and records
-
OK. I need help with a lot of stuff. This is an applescript I made to be a lot like the game Jotto, except one player. Here it is:
set yescontinue to true
set totallyfinished to false
set tip10jots to false
repeat while totallyfinished is false
repeat while yescontinue is true
set finish to false
set totallyfinished to true
set yescontinue to false
set x to {"abaca", "abaci", "aback"}
set setx2 to {"ninth", "nipas", "nippy"}
set abcde to (random number from 1 to 2)
if abcde is 1 then
set y to (some item of x)
else
set y to (some item of setx2)
end if
set z to count characters of y
set y to characters of y as list
if z is 5 then
set yescontinue to true
end if
set guessamount to 0
set listofrecords to ""
set recordofgame to {}
if yescontinue is true then
repeat while finish is false
set jots to 0
set guess1 to text returned of (display dialog "Please type your guess:" default answer "")
set zguess to count characters of guess1
if zguess is 5 then
set kldsafjhlasdkjfhaslkdjfhalskdjfh to true
else
display dialog "Please only use 5 letter words."
if yescontinue is true then
set yescontinue to false
end if
end if
if yescontinue is true then
set guess1 to characters of guess1 as list
repeat with theletter in y
repeat with theletter2 in guess1
if (theletter as string) is (theletter2 as string) then
set jots to jots + 1
end if
end repeat
end repeat
set guessamount to guessamount + 1
if jots is 1 then
set listofrecords to listofrecords & guessamount & ". " & guess1 & " " & jots & " jot" & return
else if jots is 5 then
if (guess1 as string) is (y as string) then
display dialog "You win! The entire game:" & return & return & listofrecords
else
set jots to 10
set tip10jots to true
end if
else
set listofrecords to listofrecords & guessamount & ". " & guess1 & " " & jots & " jots" & return
end if
set listofrecords to listofrecords as string
if jots is 1 then
if tip10jots is true then
display dialog "OK. " & guess1 & " was " & jots & " jots. That was guess #" & guessamount & ". Tip: Ten jots means you have all of the letters correct, but they're in the wrong order. Here is the entire game so far:" & return & return & listofrecords
else
display dialog "OK. " & guess1 & " was " & jots & " jot. That was guess #" & guessamount & ". Here is the entire game so far:" & return & return & listofrecords
end if
else
if tip10jots is true then
display dialog "OK. " & guess1 & " was " & jots & " jots. That was guess #" & guessamount & ". Tip: Ten jots means you have all of the letters correct, but they're in the wrong order. Here is the entire game so far:" & return & return & listofrecords
else
display dialog "OK. " & guess1 & " was " & jots & " jots. That was guess #" & guessamount & ". Here is the entire game so far:" & return & return & listofrecords
end if
end if
else
set yescontinue to true
end if
end repeat
end if
end repeat
end repeatAs you can see, I only have 6 sample words to save time compiling and running for now on my bad computer.
I need help creating a record instead of listofrecords, and also if anybody could shorten all the extra code I probably have. I also would like to limit being able to guess fake words, for example guessing aaaaa. Thank you so much, and if you have any ideas to help, please let me know.

