This scriptlet allows you to flip a coin and return the results 1 of 4 ways
1) echo it out to active window
2) msg it out to specified channel/user
3) notice it out to channel/user
4) return it (for using as a custom identifyer)
USAGE:
to flip a coin for you to see
/flipcoin
or
/flipcoin -e
to flip a coin to a channel as a message
/flipcoin -c #channel
to flip a coin to a channel as a notice
/flipcoin -n #channel
to get the result to use in another script
%result = $flipcoin(-r)
to get the result output as result of the !flip trigger
on *:TEXT:!flip:#: {
/flipcoin -c $chan
}
if anyone has any ideas on how to improve this then i will modify and post :)
alias flipCoin {
var %coin = $rand(1,2)
var %result
if (%coin == 1 ) {
%result = Heads
}
else {
%result = Tails
}
if (($1 == -e ) || ($len($1) == 0) ) {
/echo -a You Flip a coin
/echo -a The Coin Lands: %result
}
elseif ($1 == -c) {
if ($len($2) >= 2 ) {
if ($chan($2).status == joined) {
/msg $2 $me Flips a coin
/msg $2 The Coin Lands: %result
}
else {
/echo -a Cannot flip a coin to a channel you are not in
}
}
else {
/echo -a Cannot flip to channel as none specified
}
}
elseif ($1 == -n) {
if ($len($2) >= 2 ) {
if ($chan($2).status == joined) {
/msg $2 $me Flips a coin
/msg $2 The Coin Lands: %result
}
else {
/echo -a Cannot flip a coin to a channel you are not in
}
}
else {
/echo -a Cannot flip to channel as none specified
}
}
elseif ($1 == -r) {
return %result
}
}