mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2013
Posts: 49
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Nov 2013
Posts: 49
Is there a way to eliminate the identifier in $msg($1, <-- that Alias Message)

So that alias msg changes "msg $1 /me || $2" the $1 out to $chan depending on where it's being used? if it's used in on *:TEXT: it needs to be $chan, in alias $1.

Code:
alias msg {
  msg $1 /me || $2
}

alias aliasName {
 $msg($1,Alias Message)
}

on *:TEXT:!command*:#: {
 $msg($chan,Command Message)
}


Appreciated,
lindenkron

Last edited by lindenkron; 24/11/13 05:05 AM.
Joined: Aug 2013
Posts: 81
I
Babel fish
Offline
Babel fish
I
Joined: Aug 2013
Posts: 81
Sorry, not exactly sure what you're asking here.

The $N ($1, $2, etc. excluding $0) identifiers simply refer to the Nth token/argument passed to a script/alias/etc (comma delimited if an identifier, otherwise space delimited, by default) so $1 could easily be $chan if you want it to be..(?)

Joined: Nov 2013
Posts: 49
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Nov 2013
Posts: 49
My apologies, poorly worded. I'm wondering if there's an option for this:
Code:
alias msg {
  If alias {msg $1 /me || $2} ;; Obiously don't know the code
  If on:text {msg $chan /me || $2) ;; same goes
}

alias aliasName {
 $msg(Alias Message)
}

on *:TEXT:!command*:#: {
 $msg(Command Message)
}


To avoid having to give an identifier every time the %msg() is used.

Hope that's clearer, thank you! smile

Joined: Jul 2006
Posts: 4,150
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,150
First, /msg is a builtin command, if you create a custom alias available globally (no -l switch used), people who call /msg will call your alias instead of the built-in, so that's very bad practice, especially if you are new.

Now, let's assume you named the alias 'my_msg'.

Calling $my_msg() is not required and not useful, and can even be problematic.
When you call an alias as an $identifier, most of the time it's because you want to return a value from it, if you already know you will never have to return a value from it, you don't need to call the alias as an identifier, calling it as a command is prefered.
Regardless, it works for you here because you're not returning a value from 'my_msg', if you were to return a value like '5', that value would be interpreted as the command, and /5 would be executed, which is not something you want.

They are various way to pass the information to the alias according to which event occurs.
-if called as an identifier and assuming you're not already using properties, you can use them to pass the information:

$my_msg($1,message).called_from_alias
$my_msg($chan,message).called_from_event

inside the alias, $prop would refer to 'called_from_alias' and/or 'called_from_event'.

-you can pass the information as a parameter to the identifier/command

But in this typical situation, it's not to the /my_msg alias to figure out things, it's up to the routine calling it to pass the correct information, the location and the message:

Code:
alias my_msg {
msg $1 $2-
}

alias aliasName {
 my_msg $1 Alias Message
}
on *:TEXT:!command*:#:{
 my_msg $chan Command Message
}


Now, sometimes you need to know from which routine you called the alias (just not needed here) and in this case you pass a parameter:

Code:
alias my_msg {
if ($1 == alias) msg $2 Alias: $3-
elseif ($1 == event) msg $2 event: $3-
elseif ($1 == whatever) ...
}

alias aliasName {
 my_msg alias $1 Alias Message
}
on *:TEXT:!command*:#:{
 my_msg event $chan Command Message
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2013
Posts: 49
L
Ameglian cow
OP Offline
Ameglian cow
L
Joined: Nov 2013
Posts: 49
So your reply Wims is "No"?

A lot of this confuses me. What does what, and what is required to do what. Think I'll just leave it.

Last edited by lindenkron; 24/11/13 06:35 PM.

Link Copied to Clipboard