i dont know if this is really useful to be honest i was just bored lol
menu * {
.rps:dialog -m rps rps
}
dialog rps {
title "Rock Paper Scissors"
size -1 -1 250 165
option pixels
box "Settings", 1, 5 5 240 155
button "Rock" 10, 75 25 100 20
button "Scissors" 11, 75 75 100 20
button "Paper" 12, 75 50 100 20
edit "" 16, 15 105 210 20, read autohs
edit "" 17, 15 130 210 20, read autohs
}
on *:DIALOG:rps:sclick:*:{
if ($did = 10) { set %choice 1 | win }
if ($did = 11) { set %choice 2 | win }
if ($did = 12) { set %choice 3 | win }
}
alias win {
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 }
if (%rps.game = rock) && (%choice = 1) { did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 we tied! }
elseif (%rps.game = paper) && (%choice = 3) { did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 we tied! }
elseif (%rps.game = scissors) && (%choice = 2) { did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 we tied! }
elseif (%rps.game = rock) && (%choice = 2) { did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 you lose!
}
elseif (%rps.game = paper) && (%choice = 1) {
did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 you lose!
}
elseif (%rps.game = scissors) && (%choice = 3) {
did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 you lose!
}
elseif (%rps.game = rock) && (%choice = 3) {
did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 you win!
}
elseif (%rps.game = paper) && (%choice = 2) {
did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 you win!
}
elseif (%rps.game = scissors) && (%choice = 1) {
did -ra $dname 16 you picked $replace(%choice,1,rock,2,scissors,3,paper) and i chose %rps.game | did -ra $dname 17 you win! }
}
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.