execution at the wrong spot

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

Hi Hendo,

simply put the commands for setting the result text fields at the end. If you need initial zero values you can either set them in Interface Builder or in an Awake from nib handler.

Btw.: As far as I rmember this game from my childhood … I think your solution is a little bit too complicated. Here my attempt to shorten it a little bit:

property playerscore : 0
property cpuscore : 0
property rps_list : {"Rock", "Paper", "Scissors"}
on clicked theObject
	if the name of theObject is equal to "play_button" then
		-- set the list_count to the count of rps_list -- isn't this fixed to 3??? k - maybe you need it for further development of your game ...
		set pick to random number from 1 to 3 -- list_count
		set playerchoice to the current column of matrix "player_choice" of window "mainWindow"
		set the contents of text field "playerchoice_text" of box "result_box" of window "mainWindow" to "Player chose: " & (item playerchoice of rps_list)
		set the contents of text field "cpuchoice_text" of box "result_box" of window "mainWindow" to "Computer chose: " & (item pick of rps_list)
		if playerchoice = pick then
			set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "Tie Game!"
		else if ((playerchoice + 1 = pick) or (playerchoice = 3 and pick = 1)) then
			set cpuscore to cpuscore + 1
			set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "You Lose!"
		else
			set playerscore to playerscore + 1
			set the contents of text field "outcome_text" of box "result_box" of window "mainWindow" to "You Win!"
		end if
		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
	end if
end clicked

D.