simple math game

set user_score to "0" as integer
repeat 5 times
	set first_number to (random number from 0 to 100) as string
	set second_number to (random number from 0 to 100) as string
	set the_question to display dialog first_number & " + " & second_number & " = ?" default answer ""
	set user_answer to (text returned of the_question) as string
	set the_answer to (first_number + second_number) as string
	
	if user_answer is not equal to the_answer then
		display dialog "Incorrect!"
	else
		display dialog "Correct!"
		set user_score to user_score + 1
	end if
end repeat
display dialog "You scored " & user_score & "/5"
set register to display dialog "Thanks for using the math game script! Please register the full version. It only costs $1,000,000,000,000,000." buttons {"Register Now"} default button 1
set register_choice to (button returned of register) as string
if register_choice is equal to "Register Now" then
	display dialog "JUST KIDDING!" buttons {"Ok"}
end if

How about this?


set quiz_speed to button returned of (display dialog return & space & space & space & "Which quiz speed do you choose?" with icon file "Macintosh HD:System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:GenericQuestionMarkIcon.icns" buttons {"Slow", "Normal", "Fast"})

if quiz_speed is "Slow" then
	set theDelay to 10
else
	if quiz_speed is "Normal" then
		set theDelay to 5
	else
		if quiz_speed is "Fast" then
			set theDelay to 3
		end if
	end if
end if

set user_score to 0
repeat 5 times
	set first_number to (random number from 0 to 100) as string
	set second_number to (random number from 0 to 100) as string
	set the_question to display dialog first_number & " + " & second_number & " = ?" default answer "" with icon alias "Macintosh HD:Applications:Calculator.app:Contents:Resources:Calculator.icns" giving up after theDelay
	set user_answer to (text returned of the_question) as string
	set the_answer to (first_number + second_number) as string
	
	if user_answer is not equal to the_answer then
		beep
		display dialog return & "Incorrect!" & return & "The answer was " & the_answer & "." with icon file "Macintosh HD:System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:AlertStopIcon.icns" giving up after 3
	else
		display dialog return & "Correct!" with icon file "Macintosh HD:System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:AlertNoteIcon.icns" giving up after 1
		set user_score to user_score + 1
	end if
end repeat

display dialog return & "You answered " & user_score & " of 5 correctly." with icon alias "Macintosh HD:System:Library:CoreServices:Finder.app:Contents:Resources:info.icns" giving up after 7
set register to display dialog "Thanks for using the math game script! Please register the full version. It only costs $1,000,000,000,000,000." buttons {"Register Now"} default button 1 giving up after 7
set register_choice to (button returned of register) as string
display dialog return & "JUST KIDDING!" with icon file "Macintosh HD:System:Library:CoreServices:CoreTypes.bundle:Contents:Resources:FinderIcon.icns" buttons {"Ha Ha!"} default button 1
end