guest598594 commented on a Page, Rock paper scissors  -  Jul 29, 2008

In the dialog, when you choose something, why not set the var as the item chosen instead of a number? That\'ll save you the $replace\'s later on.

And btw, you can call an alias with parameters, so you could skip the var and just do \"win rock\" or \"win scissors\" and then refer to that as $1.

Also,

  set %rps $rand(1,3)
  if (%rps = 1) { set %rps.game Rock }
  elseif (%rps = 2) { set %rps.game paper }
  elseif (%rps = 3) { set %rps.game scissors } 

I\'d use /var, and you could do

  var %rps = $gettok(Rock Paper Scissors,$r(1,3),32)

And in the rest of the win alias, since you repeat one action in every if, all you really have to do is

  did -ra $dname 16 You picked $replace(%choice,1,rock,2,scissors,3,paper) and I chose %rps.game
  if (%rps.game == paper) && (%choice == 1) { did -ra $dname 17 you lose! }
  ;etc.

But as I said earlier, if you set the var as the action instead of a number, you could simply check if (%rps.game == %choice) for ties.

 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.