Buggsy   -  Jun 04, 2014

Can anyone help me by showing me how to make a random play for a .mrc popup script I made? That way I wouldn't have to keep scrolling through all of the numerous popups and select one every time. Thanks in advance.

Arigateaux  -  Jun 09, 2014

What do you mean by a random play?

Buggsy  -  Jun 10, 2014

I mean that you type a command and the script chooses a random popup from the list of available popups and displays it on the screen instead of you having to manually choose one to play.

Meta  -  Jun 17, 2014

What I suggest is that you put all of the popups in a plain text file - one per line, save it to your $mircini directory, and then make use of the following identifiers:

[list=1][]$read() to read from the file, with the option to return one specifically or at random
[
]$submenu() to generate the popup menu dynamically[/list]

So, for example, let's say I have the following popups in a file called stupidreactions.txt (saved to my $mircini directory):

&Blink:me blinks | say ... what, $?1 $+ ..?
&Stare:me stares at $?1 $+ ... | say o_o . . . . . . . 
&Facepalm:say >_<\
Sha&ke:me shakes head at $?1 $+ ... | say /(-_- ), /( -_-), /(-_- )

I could then place the following codes in my remotes to generate a list of those popups dynamically, as well as an option to return one at random:

menu nicklist,channel,query {
  -
  &Stupid Reactions
  .$submenu($stupidreactions($1))
}

alias -l stupidreactions {
  if $isfile(stupidreactions.txt) {
    if $1 == begin { return Random: $+ $gettok($read(stupidreactions.txt,nt),2-,58) }
    elseif $istok(1 end,$1,32) { return - }
    else return $read(stupidreactions.txt,nt,$calc($1 - 1))
  }
}

Hopefully the menu definition should be fairly self-explanitory. The $submenu identifier is explained in more detail in the help file...

The stupidreactions alias might need a little more explanation however. ..

First, check to ensure that the file being read from actually exists. If it does, the alias can continue to be used to generate the list of popups. Once confirming that the file exists, if $1 is begin, create an option called Random that returns one of the popups at random. (The n and t switches are used with $read() to return the line in plain text and to prevent mIRC from treating the first line as a line count if it had happened to be a number, respectively. $gettok( . . . ,2,58) is used to strip the option name from the line and return only the command(s)), Otherwise, if $1 is either end or 1, generate popup options separators: -. Finally, if none of the above conditions are true (i.e. $1 is a number greater than 1), subtract 1 from the value of $1, and then use the $read() identifier to generate the popup options based on that value. (The n and t switches serve the same purpose mentioned above).

I hope this makes sense. If you need anymore help, just let me know.

Sign in to comment

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.