Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- write mIRC code for a rock scissors paper game. Write an alias "choose" that returns rock, scissors or paper using $rand(1,3) to play the respective choice against the player. When a game is triggered set a variable "play" with the value of the"choose" alias and then figure out who won by comparing the players choice to the value that choose returned.
- Here's the mIRC code for a rock-paper-scissors game using an "alias" named "choose" to randomly select the computer's choice:
- perl
- ; Rock-paper-scissors game
- alias choose {
- var %choice = $rand(1,3)
- if (%choice == 1) {
- return rock
- }
- elseif (%choice == 2) {
- return paper
- }
- else {
- return scissors
- }
- }
- on *:TEXT:!rps*:#: {
- set %play $choose
- msg # You chose $2-
- msg # The computer chose %play
- if ($2 == rock && %play == scissors || $2 == paper && %play == rock || $2 == scissors && %play == paper) {
- msg # You win!
- }
- elseif ($2 == %play) {
- msg # It's a tie!
- }
- else {
- msg # The computer wins!
- }
- }
- To use the game, simply type "!rps rock" (or "paper" or "scissors") in a channel where the bot is present, and it will play a round of rock-paper-scissors against you. The "on TEXT" event triggers whenever someone types "!rps" followed by a choice, and sets the "%play" variable to the computer's random choice using the "choose" alias. The script then compares your choice to the computer's choice to determine the winner and sends a message to the channel indicating the outcome of the game.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement