Lucius commented on a Page, Number Game  -  Aug 26, 2010
on *:text:*!newgame*:%ng: {
  if (%high == $null) set %high 15
  if (%gswitch == on) {  msg %ng $ja $+ 8,1 There is a game in progress, Please finish this game first. Type !guess and your number  $+ $ja | HALT }
  else { set %rn $rand(0,1000) | set %gswitch on | msg %ng 4 A new game has started. Type !guess and a number from 1 to 1,000 Good Luck!  | echo 3 -a %rn
    msg %ng $ja $+ 8,1 $read(highscore.ini) holds Low Score of %high  $+ $ja
  }
}

for example...

The goto play was only needed to skip the if which was actually the opposite of the previous one (you could use else as I did, or leave it there, because the variable cannot be == on (and also) != on.
The goto game was redundant because it was the end anyway, you could just use halt.

same for the !guess trigger with the goto parts. goto is only useful if you need to get to that section of the script from multiple points, if it's only used once, it is easier to do this:

  if ($2 < %rn) goto tolow
  if ($2 > %rn) goto tohigh
  if ($2 == %rn) goto won
  else goto nogame
  :tolow
  msg %ng Sorry that number is to low try again
  halt
  :tohigh
  msg %ng Sorry that number is to high, try again
  halt
  :won
  msg %ng $ja $+ 9,1 Congratulations $nick you guessed the number.   ETC ETC

INSTEAD USE:

if (!$2) { msg %ng You forgot to type a number! | HALT }
  elseif ($2 < %rn) { msg %ng Sorry that number is to low try again | HALT }
  elseif ($2 > %rn) {   msg %ng Sorry that number is to high, try again | HALT }
  else {
    msg %ng $ja $+ 9,1 Congratulations $nick you guessed the number. ETC ETC

I also added in one for if there is no number. You can add that at the start to quick stop it, or let it inc the %tries if you wish first, so it counts as a bad guess.

I tend to put the goto etc command inside unobtainables so I know they will not activate accidentally like this

  if (%ex == %ex2) { goto example }
  if (1 == 2) {
    :example
    blah blah script stuff
  }

hope that wasn't too impossible for you to understand, I know how it can be looking at a different style and feeling lost. (for me it's regex @_@)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.