mIRC Home    About    Download    Register    News    Help

Print Thread
Probably aliases? Script for using multiple times #262694 14/03/18 08:03 PM
Joined: Mar 2018
Posts: 9
S
Smokofenek Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Mar 2018
Posts: 9
Okay. I don't get how the aliases works. Completely. I need to make some if statements to be used by few other commands.

One is set of nicknames, that I want to change.

Code:
if ($nick == nick) var %nick = NiCK
      elseif ($nick == anothernick) var %nick = AnotherNick
      elseif ($nick == supercoolguy) var %nick = SuperCoolGUY
      else var %nick = $nick


Sth like this. But how to make an alies (or whatever to allow me using this in plenty of scripts)?

I want the bot to know that when I wrote %nick, he should do if statement to check what the nick is and change it to appropriate nickname.

The same thing goes with if statement with (currently) 667 if/elseifs, so I don't have to copy that large ammount of code (2000 lines...) just to make command using the same vars. Second one looks like that:

Code:
var %rch = $rand(1,667)
      if (%rch == 1) {
        var %pre = Dark Sun
        var %char = Gwyndolin
      }
      elseif (%rch == 2) {
        var %pre = Black Dragon
        var %char = Kalameet
      }


It would be pretty stupid to make this pasted any time I need it, except for some alias thing or what the mirc need to storage this data.

Thanks in advance.

Re: Probably aliases? Script for using multiple times [Re: Smokofenek] #262695 14/03/18 08:37 PM
Joined: Jul 2006
Posts: 3,584
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,584
Code:
alias formatnick {
var %nick
if ($1 == nick) %nick = NiCK
elseif ($1 == anothernick) %nick = AnotherNick
elseif ($1 == supercoolguy) %nick = SuperCoolGUY
else %nick = $1
return %nick
}
Put that in remote and now you can use it as a function, $formatnick($nick)

Same idea for the other thing

Code:
alias getstuff {
 var %rch = $rand(1,667),%pre,%char
 if (%rch == 1) {
    %pre = Dark Sun
    %char = Gwyndolin
  }
  elseif (%rch == 2) {
     %pre = Black Dragon
     %char = Kalameet
  }
 elseif () {

  }
return %char %pre
}
and then $getstuff return %char as the first word and %pre as the rest, so in your script you would use something like var %stuff $getstuff,%char $gettok(%stuff,1,32),%pre $gettok(%stuff,2-,32)


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Probably aliases? Script for using multiple times [Re: Wims] #262696 14/03/18 09:29 PM
Joined: Mar 2018
Posts: 9
S
Smokofenek Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Mar 2018
Posts: 9
Oh my. The first one is pretty easy to understamnd for me... but second one... I try to understand...

If there is more variables, like for example, then I just give next number, right? And the "-" symbol means it's more than one word? Can I do $gettok(%stuff,1-,32) if the $char is more than one word long? Also... I can make alias with all variables, but can I give some %rch less variables? Sometimes there is only %char, ontimes it's %su and %char, sometimes %char and %pre.

Re: Probably aliases? Script for using multiple times [Re: Smokofenek] #262697 15/03/18 12:25 AM
Joined: Jul 2006
Posts: 3,584
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,584
I saw in your code that %pre has a value with a space while %char does not, I assumed this would be true for all the cases.

Code:
return %char %pre
This was used because %char does not have space while %pre will (or may have some spaces) so currently, $getstuff returns for example "Gwyndolin Dark Sun", with the above assumption, you know that the first word in this represent the %char variable in the function, because %char never has a space (or so we assume). So first word = char = Gwyndolin and the 'rest' (from the second word onward) is your %pre, here it's "Dark Sun"
The assumption is also that you may have more than one space in %pre, and in this case we wouldn't know how many spaces there is beforehand, so you couldn't calculate in $gettok, that's why i made it this way: you know the first word is always one thing, while the rest is the other thing.

I suggest you read the documention about $gettok https://en.wikichip.org/wiki/mirc/identifiers/$gettok which also explain the 1- usage etc

If %char can contain spaces, then you need to find a character that won't ever occur in any of the string, let's say '@', then the return would be "return %char $+ @ $+ %pre" now you are returning a value of the format stuff@stuff and you can use the '@' as a token seperator (like we were using space as a token seperator) with $gettok and get each part, $gettok(abc@123,1,64) = abc and $gettok(abc@123,2,64) = 123, 64 is the 'ascii' number of the character seperating the tokens.

Quote:
I can make alias with all variables, but can I give some %rch less variables? Sometimes there is only %char, ontimes it's %su and %char, sometimes %char and %pre.
This is a bit unclear but if you are sometimes using %su instead of %char, well then you would rewrite the code to use %char everywhere. If you are saying that you sometimes have 3 variables to return, well then another, similar, strategy must take place, you would need to pastebin the full code so that a logic can be made out of it


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Probably aliases? Script for using multiple times [Re: Wims] #262704 15/03/18 12:24 PM
Joined: Mar 2018
Posts: 9
S
Smokofenek Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Mar 2018
Posts: 9
Uh, okay. But the code is pretty long. 3000 lines.

Code:
var %nickk = $formatnick($nick)
      var %age = $rand(1,30) * $len($1-$100)
      var %rch = $rand(1,667)
      if (%rch == 1) {
        var %pre = Dark Sun
        var %char = Gwyndolin
      }
      elseif (%rch == 2) {
        var %pre = Black Dragon
        var %char = Kalameet
      }

(...)

      elseif (%rch == 11) {
        var %char = Gwyn
        var %suchar = $chr(44)
        var %su Lord of Cinder
      }
      elseif (%rch == 12) {
        var %char = Seath
        var %su = the Scaleless
      }
(...)
var %nn = %pre $+(%prechar,%char,%suchar) %su
var %event = $rand(1,7)
(...........)


This is how the code looks like now, but I'm completely going to rewrite this. Because.

%even is variable that makes some message appear. One is fusion that gets first 4 characters of the %char and last 4 chars of $formatnick($nick) or vice versa. %nn, as You can see is pretty more complex, because it makes it be like Prefix SubprefixNameSubsufix Sufix. But instead of this, I'm just gonna do few different states and only one variable (or two at most) will be used.

gonna do sth like:

%fullname
%name
%nick
%fusion

And regarding on which script I want, the %rch that was randomized will give different var.

The reason I had prefixes/subprefixes/etc was because I wanted to make %char to be simple name of character but with all pre/sufixes will give its full name. But i got some problems with it because sometimes names are exactly the same as full name, sometimes names are exaclty the same as nicknames etc.

This is what I was recently thinking when I wanted to change it:

Code:
Nick: East Kaioshin
Full: East Kaioshin
Name: Shin
Fusion: Shin

Nick: Assylum Demon
Full: Assylum Demon
Name: Assylum Demon
Fusion: Assylum

Nick: Seath the Scaleless
Full: Seath
Name: Seath
Fusion: Seath

Nick: Tracer
Full: Lena Oxton
Name: Lena
Fusion: Lena

Nick: D.Va
Full: Hana Song
Name: Hana
Fusion: Hana Song

Nick: Sam
Full: Samantha Simpson
Name: Samantha
Fusion: Samantha

Nick Full
Name
Fusi/sion


So it will have pretty much such things.

And the script will use different variables in different places, like I want just a fusion name to fusion script, but I want full name to appear when I want it to say full name etc. That's what I thinked.

If this is too complicated to do, I can still make sth like one script:

Code:
on *:TEXT:!script*:#: {
if (!$2) { msg $chan Some help with using scripts, saying subscript commands }
elseif ($2 == Fusion) { Fusion script }
elseif ($2 == AnotherScript) { Another Script }
}

So it will be one big script with subscript commands, instead of making it few scripts. Will it be better in my case?

Currently this script is made for automatically happen after sendint 23 messages on chat, so it has

Code:
on *:TEXT:*:#:


instead of specific text and increases variable, and when it's specific number, then the script happens.

Code:
[AUTOSCRIPT]
on *:TEXT:*:#: {
  INC %msgScript {
    if (%msgScript = 23) { AND THERE IS THE SCRIPT }


The reason I actually wanted it to be universal is because this one was meant to be autoscript, but I have old scripts, using randomizing characters from games etc too and didn't want them to be separated. But I think I can just combine them and remove automation from it.

Will it be better in my case?