Well, I’m working on the Rock, Paper, Scissors app, and it’s workin pretty dandy except for one part. So far the style of game is you have a matrix with three choices (rock, paper, scissors) you pick one then hit the play button. This will do the outcome of that game. the problem is that say you get 1 point, it doesn’t show that point until you click the play button again.
property playerscore : 0
property cpuscore : 0
on clicked theObject
if the name of theObject is equal to "play_button" then
tell window "mainWindow"
set the contents of text field "playerscore" of box "score_box" to playerscore as string
set the contents of text field "cpuscore" of box "score_box" to cpuscore as string
end tell
set rps_list to {"Rock", "Paper", "Scissors"}
set the list_count to the count of rps_list
set pick to random number from 1 to list_count
set cpu_choice to item pick of rps_list as string
set playerchoice to the current column of matrix "player_choice" of window "mainWindow" as string
if playerchoice is equal to "1" then
set the contents of text field "playerchoice_text" of box "result_box" of window "mainWindow" to "Player chose: Rock"
set the contents of text field "cpuchoice_text" of box "result_box" of window "mainWindow" to "Computer chose: " & cpu_choice
else if playerchoice is equal to "2" then
set the contents of text field "playerchoice_text" of box "result_box" of window "mainWindow" to "Player chose: Paper"
set the contents of text field "cpuchoice_text" of box "result_box" of window "mainWindow" to "Computer chose: " & cpu_choice
else if playerchoice is equal to "3" then
set the contents of text field "playerchoice_text" of box "result_box" of window "mainWindow" to "Player chose: Scissors"
set the contents of text field "cpuchoice_text" of box "result_box" of window "mainWindow" to "Computer chose: " & cpu_choice
end if
if playerchoice is equal to "1" and cpu_choice is equal to "Rock" then
set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "Tie Game!"
else if playerchoice is equal to "1" and cpu_choice is equal to "Paper" then
set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "You Lose!"
set cpuscore to cpuscore + 1
else if playerchoice is equal to "1" and cpu_choice is equal to "Scissors" then
set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "You Win!"
set playerscore to playerscore + 1
else if playerchoice is equal to "2" and cpu_choice is equal to "Rock" then
set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "You Win!"
set playerscore to playerscore + 1
else if playerchoice is equal to "2" and cpu_choice is equal to "Paper" then
set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "Tie Game!"
else if playerchoice is equal to "2" and cpu_choice is equal to "Scissors" then
set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "You Lose!"
set cpuscore to cpuscore + 1
else if playerchoice is equal to "3" and cpu_choice is equal to "Rock" then
set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "You Lose!"
set cpuscore to cpuscore + 1
else if playerchoice is equal to "3" and cpu_choice is equal to "Paper" then
set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "You Win!"
set cpuscore to cpuscore + 1
else if playerchoice is equal to "3" and cpu_choice is equal to "Scissors" then
set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "Tie Game!"
end if
end if
end clicked