mIRC Home    About    Download    Register    News    Help

Print Thread
#267775 24/09/20 07:25 PM
Joined: Sep 2020
Posts: 1
P
Poul Offline OP
Mostly harmless
OP Offline
Mostly harmless
P
Joined: Sep 2020
Posts: 1
I'm trying to write a simple script for BeanBoozeled Jelly beans, you hit a trigger
then it chooses a good or bad bean
then randomly chooses which bean

I'm having an issue to get it go from

on *:text:!BeanB:#PoulsKitchen:{

set %victem $nick
set %beanch #PoulsKitchen
set %badorgood $rand(1,2)
if (%badorgood == 1) set %givebadbean badbean
if (%badorgood == 2) set %givebadbean goodbean
}


At the end of this it needs to go to the good bean section or bad bean section, not sure where to from here,

here is the entire script

on *:text:!BeanB:#PoulsKitchen:{

set %victem $nick
set %beanch #PoulsKitchen
set %badorgood $rand(1,2)
if (%badorgood == 1) set %givebadbean badbean
if (%badorgood == 2) set %givebadbean goodbean
}


set -kl %badcount + 1

set %rbad $rand(1,25)

if (%rbad == 1) msg %beanch Hands %victem a Black Pepper 15,1( 4Black15 4Pepper15 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 2) msg %beanch Hands %victem a Tabassco 4,1( 56Tabassco4 )1,0Ohhh You've Been BeanBoozeled
elseif (%rbad == 3) msg %beanch Hands %victem a Booger 56,1( 4Bouger56 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 4) msg %beanch Hands %victem a Dirt 5,1( 41Dirt5 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 5) msg %beanch Hands %victem a Garbage 40,1( 4Garbage40 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 6) msg %beanch Hands %victem a Earthworm 54,1( 5~~~78Earth Worm5~~~54 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 7) msg %beanch Hands %victem a Garlic 30,1( 4Garlic30 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 8) msg %beanch Hands %victem a Grass 56,1( 4Grass56 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 9) msg %beanch Hands %victem a Rotten Egg 0,1( Rotten Egg )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 10) msg %beanch Hands %victem a Soap 0,1( Soap )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 11) msg %beanch Hands %victem a Vomit 9,1( 4Vomit9 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 12) msg %beanch Hands %victem a Dirty Dishwasher 14,1( 54Dirty Dishwater14 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 13) msg %beanch Hands %victem a Stink Bug 52,1( 62Stink Bug52 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 14) msg %beanch Hands %victem a Stinky Socks 0,1( 52Stinky Socks0 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 15) msg %beanch Hands %victem a Spoiled Milk 0,1( 78Spoiled Milk0 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 16) msg %beanch Hands %victem a Toothpaist 63,1( 0Tooth Paste63 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 17) msg %beanch Hands %victem a Canned Dog Food 5,1( 54Canned Dog Food5 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 18) msg %beanch Hands %victem a Barf 28,1( 13Barf28 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 19) msg %beanch Hands %victem a Dead fish 62,1( 0Dead Fish62 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 20) msg %beanch Hands %victem a Lawn Clippings 9,1( 52Lawn Clippings9 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 21) msg %beanch Hands %victem a Skunk Spray 0,1( 52Skunk Spray0 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 22) msg %beanch Hands %victem a Baby Whipes 0,1( 54Baby Whipes0 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 23) msg %beanch Hands %victem a Pencil Shavings 14,1( 54Pencil Shavings14 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 24) msg %beanch Hands %victem a Centipede 13,1( 80Centipeed13 )1,0 Ohhh You've Been BeanBoozeled
elseif (%rbad == 25) msg %beanch Hands %victem a Earwax 7,1( 9Ear Wax7 )1,0 Ohhh You've Been BeanBoozeled



set -kl %goodcount + 1
set %rgood $rand(1,25)

if (%rgood == 1) msg %beanch Hands %victem a Berry Blue 12,1(52 Berry Blue12 )1,0 Enjoy The Bean
elseif (%rgood == 2) msg %beanch Hands %victem a Blueberry 60,1( 52Blueberry60 )1,0Enjoy The Bean
elseif (%rgood == 3) msg %beanch Hands %victem a Bubblegum 62,1( 52Bubblegum62 )1,0Enjoy The Bean
elseif (%rgood == 4) msg %beanch Hands %victem a Buttered Popcorn 70,1( 52Buttered Popcorn70 )1,0Enjoy The Bean
elseif (%rgood == 5) msg %beanch Hands %victem a Cantelope Melon 54,1( 52Cantelope Melon54 )1,0Enjoy The Bean
elseif (%rgood == 6) msg %beanch Hands %victem a Cappuccino 5,1( 66Cappuccino5 )1,0Enjoy The Bean
elseif (%rgood == 7) msg %beanch Hands %victem a Caramel Corn 8,1( 52Caramel Corn8 )1,0Enjoy The Bean
elseif (%rgood == 8) msg %beanch Hands %victem a Chocolate Pudding 5,1( 56Chocolate Pudding5 )1,0 Enjoy The Bean
elseif (%rgood == 9) msg %beanch Hands %victem a Cinnimon 4,1 ( 54 Cinnimon4 )1,0Enjoy The Bean
elseif (%rgood == 10) msg %beanch Hands %victem a Cotton Candy 13,1( 3Cotton Candy 13 )1,0Enjoy The Bean
elseif (%rgood == 11) msg %beanch Hands %victem a Cream Soda 13,1 ( Cream Soda ) 1,0Enjoy The Bean
elseif (%rgood == 12) msg %beanch Hands %victem a Crushed Pineapple 54,1 ( Crushed Pinnaple ) 1,0Enjoy The Bean
elseif (%rgood == 13) msg %beanch Hands %victem a Vanilla 0,1( Vanilla )1,0Enjoy The Bean
elseif (%rgood == 14) msg %beanch Hands %victem a Green Apple 9,1( Green Apple )1,0Enjoy The Bean
elseif (%rgood == 15) msg %beanch Hands %victem a Island Punch 13,1 ( Island Punch )1,0Enjoy The Bean
elseif (%rgood == 16) msg %beanch Hands %victem a Juicy Pear 3,1 ( Juicy Pear )1,0Enjoy The Bean
elseif (%rgood == 17) msg %beanch Hands %victem a Kiwi 9,1 ( Kiwi )1,0Enjoy The Bean
elseif (%rgood == 18) msg %beanch Hands %victem a Lemon 54,1( Lemon )1,0Enjoy The Bean
elseif (%rgood == 19) msg %beanch Hands %victem a Lemon Drop 54,1( Lemon Drop ) 1,0Enjoy The Bean
elseif (%rgood == 20) msg %beanch Hands %victem a Lemon Lime 54,1( Lemon Lime )1,0Enjoy The Bean
elseif (%rgood == 21) msg %beanch Hands %victem a Lime 9,1( Lime )1,0Enjoy The Bean
elseif (%rgood == 22) msg %beanch Hands %victem a Mango 58,1 ( Mango ) 1,0Enjoy The Bean
elseif (%rgood == 23) msg %beanch Hands %victem a Margarita 63,1 (Margarita )1,0Enjoy The Bean
elseif (%rgood == 24) msg %beanch Hands %victem a Mixed Berry Smoothie 12,1( Mixed Berry Smoothy )1,0Enjoy The Bean
elseif (%rgood == 25) msg %beanch Hands %victem a Orange 7,1( Orange )1,0Enjoy The Bean


This is what i have so far, i just need it to switch to good or bad

Thank you for your help in advance.

Poul #267776 25/09/20 02:10 AM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
You can use the 'goto' command to go to a label, which is a text string beginning with a colon. You could do something like:

====
if ( $rand(1,2) ) == 1 goto goodbean
else goto badbean

:badbean
code goes here
goto label123

:goodbean
code goes here
goto label123

:label123
code goes here
==========
obviously, you didn't need the "goto badbean" since that label was on the next line. and same goes for the goto at the end of the goodbean code.

You can simplify your script by keeping your messages either in separate text files, or in a hashtable. hashtable has the advantage of being kept in memory, so you don't need a disk read each time. text file has the advantage of being easy to /play the text file and see a list of all your messages.

Also, the $read command has the random feature built into it, when you don't give it a line number to read. This example uses the 'n' switch because that prevents any word beginning with $ or % from being replaced by how they evaluate. i.e. a line in the text file containing $me would print the literal "$me" instead of using your nick.

var %message $read(goodbean.txt,nt) $+ 1,0Enjoy The Bean

This fills a variable with a random line from the text file. This way you don't need to keep adjusting your script each time you add another message. Notice how I appended the final portion of the 'good bean' message, so you don't need to put that on every line of the text. If you find it harder to put the Ctrl+K symbol into the text file when using something like notepad, you can choose a character that will never be used in any of your messages, and use that in place of the color code. For example, assume the character will be the asterisk, the text file would contain lines like:

Black Pepper *15,1( *4Black*15 *4Pepper*15 )
Garlic *30,1( *4Garlic*30 )

and then you can fetch random lines like this, while changing the asterisk back to the Ctrl+K symbol:

msg %beanch Hands %victem a $replace($read(badbean.txt,nt),*,$chr(3)) $+ 1,0 Ohhh You've Been BeanBoozeled

After you read a random line, if you need to know which line was most recently read from any disk file, the line number is contained in $readn

Something else you should change in your script is that your variables are being created as global variables which continue to be saved in your vars tab of the scripts editor long after your script is used, even though they aren't needing to be saved for later. You can make them be local by either using /set -l or using /var

var %victem $nick
var %beanch #PoulsKitchen


It looks like
set -kl %badcount + 1
is supposed to be a counter for how many times the bad routine has been hit. By using the -l flag, this creates the variable as a local variable which doesn't exist outside the ON TEXT event. What this is doing is defining the variable as the literal string "+ 1". If you want to increment a global variable, you can do it like: /inc %badcount


Link Copied to Clipboard