Combining if-then statements

i have 2 questions

  1. is there anyway i can take all those if then statements and put them in to one
  2. why cant i set (comp_num + change_num) to comp_num ?
    here is el code

repeat
	display dialog "   ****THE ULTIMATE GAME, NUMBER-GUESS�****
	                             by John C.
	      (The Greatest person to ever walk the planet)" buttons {"Continue"} default button 1
	display dialog "Rules: This is a simple guessing game, the computer randomly picks a number between 1 and 100, and you have to guess it. however if your guess isn't correct then the computer will either add of subtract one from the number. you must score 1-9 to beat the level (levels arn't enabled yet too lazy)" buttons {"Continue"} default button 1
	display dialog "soon there wil be difficulty levels here..." buttons {"Start"} default button 1
	set guess_shower to " You havn't guessed yet"
	set {low_num, high_num} to {1, 100}
	set comp_num to (random number from low_num to high_num)
	set num_guess to 0
	set change_list to {"-1", "1"}
	set change_num to (item (random number from 1 to (length of change_list)) of change_list)
	repeat
		set num_guess to num_guess + 1
		display dialog "" & guess_shower & " 
	What number do you want to guess?" default answer ""
		set the_guess to the text returned of result as number
		if the_guess is equal to comp_num then display dialog "You Win! it took you " & num_guess & " times to correctly guess my number"
		if the_guess is greater than comp_num then display dialog "Your guess was too high, I will now add or subtract 1 from my number"
		if the_guess is less than comp_num then display dialog "your number was too low, I will now subtract or add 1 to my number"
		if the_guess is greater than comp_num then set guess_shower to "your last number " & the_guess & " was too high"
		if the_guess is less than comp_num then set guess_shower to "your last guess " & the_guess & " was too low"
		if the_guess = comp_num then exit repeat
		if the_guess is less than comp_num then set (comp_num + change_num) to comp_num
	end repeat
	set play_again to the button returned of (display dialog "do you want to play again?" buttons {"Yes", "No"} default button 1)
	if play_again = "no" then exit repeat
	if play_again = "yes" then
	end if
end repeat

i realize now question # 2 was stupid and fixed i, i bet #1 is also stupid and easy to fix, but its not apparent to me

I think this is what you are after (including an increasing difficulty level by reducing the number of guesses available):

display dialog "****THE ULTIMATE GAME, NUMBER-GUESS?**** 
    ?       ?                      ?by John C. 
     (The Greatest person to ever walk the planet)" buttons {"Continue"} default button 1
set {low_num, high_num, max_guesses} to {1, 100, 9}
repeat
	display dialog "Rules: This is a simple guessing game. The computer randomly picks a number between " & low_num & " and " & high_num & " and you have to guess it. However if your guess isn't correct then the computer will either add or subtract 1 from the number. You have " & max_guesses & " chances to guess the number." buttons {"Continue"} default button 1
	set {guess_shower, comp_num, num_guess} to {"", (random number from low_num to high_num), 0}
	repeat
		set num_guess to num_guess + 1
		if num_guess > max_guesses then
			display dialog "Too bad, you didn't guess my number in " & max_guesses & " tries. My number was " & comp_num & "." buttons {"OK"} default button 1 with icon 0
			exit repeat
		end if
		if guess_shower is not "" then set guess_shower to guess_shower & return & return
		set the_guess to text returned of (display dialog guess_shower & "What number do you want to guess?" & return & return & "This is guess " & num_guess & " of " & max_guesses & "." & return & "Guess range: " & low_num & "-" & high_num & "." default answer "" with icon 1)
		try
			set the_guess to the_guess as number
			if the_guess = comp_num then
				if num_guess > 1 then
					set the_plural to " tries"
				else
					set the_plural to " try"
				end if
				display dialog "You Win! It took you " & num_guess & the_plural & " to correctly guess the number (" & comp_num & ")." buttons {"OK"} default button 1 with icon 1
				exit repeat
			else if the_guess > comp_num then
				set the_direction to "high"
			else if the_guess < comp_num then
				set the_direction to "low"
			end if
			set guess_shower to "Your last guess, " & the_guess & ", was too " & the_direction & ". I have either added or subtracted 1 from the number."
			set comp_num to (comp_num + (some item of {-1, 1}))
		on error
			set guess_shower to "Your last entry, " & the_guess & ", was not a number."
		end try
	end repeat
	if button returned of (display dialog "Do you want to play again?" buttons {"Yes", "No"} default button 1 with icon 1) = "No" then exit repeat
	set max_guesses to max_guesses - 1 --this is the level thing you wanted
	if max_guesses = 0 then
		if button returned of (display dialog "There are no more levels, do you want to start over?" buttons {"Yes", "No"} default button 1 with icon 1) = "No" then
			exit repeat
		else
			set max_guesses to 9
		end if
	end if
end repeat

Jon

two off topic question but i dont think its worth making another for sooo

  1. how do you make a simple app taht will close all running programs?
  2. hw come all you code postas are pretty while mine are in their unsaved color?

In it’s simplest form:

tell application "System Events"
	tell every application process to quit
end tell

Although you’re likely to need to add some checking to make sure you don’t quit the script itself.

Follow the link at the bottom of the code. You’ll be taken to http://homepage.mac.com/jonn8/as/ where you can get an app that converts AppleScript into tagged text suitable for pasting into discussion boards.