mIRC Homepage
Posted By: Nekomusume a more uiniversal identifier than $chan - 14/10/03 08:38 AM
ON TEXT and ON ACTION can be set to trigger from windows of all types with the * setting.

if the trigger happened to be in a channel, one can use $chan to perform actions aimed at that channel. however, if the trigger happens to be from a query window or dcc chat, $chan doesn't work. i'm not even sure if there is an equivalent for them.

ideally, there should be a single identifier (say: $source) that would identify the triggering window, regardless of type, so that, for example, we could direct echos or the like back to it easily without having to write a bunch of extra code for it. there should also be a simple identifier (say: $sourcetype) that would just return whether the source was a query window, channel window or whatever.

i'm using ON TEXT and ON ACTION primarily to redo the way dialogue in channels/chats is displayed, and while i've managed to get ON TEXT to work universally, it has some odd side effects (like everything going on in query windows being echoed to both the query window and the status window for some insane reason) and i haven't managed to get the ON ACTION to work at all in chat windows.

i have got to figure that other people are using similar (though probably better developed) workarounds.

ideally, i would love to have something like "/echo 4 $source Hello!" work identcally in ON TEXT and ON ACTION triggers from any server, channel, query and/or DCC chat window.

Posted By: Revan Re: a more uiniversal identifier than $chan - 14/10/03 08:46 AM
/help $target
nope. $target returns your own nick when triggered from query windows. (though i have no idea as to why)

this example (a simplified version of what i use ) works fine for channels, doesn't work in query windows.

on ^*:TEXT:*:*: {
echo 14 $target $nick - $$1-
haltdef
}

in order to make $target work in a query window, i had to do this:

on ^*:TEXT:*:*: {
if ( $target == $me ) { echo 14 $nick $nick said: $$1 }
if ( $chan != $null ) { echo 14 $target $nick - $nick said: $$1 }
haltdef
}

two lines to do what should be the work of one.

i haven't experiemented with DCC chats much, so i don't know what wierdnesses may be involved there. i do know that, for some reason, i have to use ON CHAT instead of ON TEXT requiring yet MORE redundant code <grr>
Posted By: Iori Re: a more uiniversal identifier than $chan - 14/10/03 10:24 AM
Code:
on ^*:TEXT:*:*: {
  echo 14 $iif($target ischan,$chan,$nick) $nick said: $$1
  haltdef
}
Posted By: Doqnach Re: a more uiniversal identifier than $chan - 14/10/03 10:54 AM
Code:
on ^*:TEXT:*:*: {
  echo 14 $iif($target == $me,$nick,$target) $nick said: $$1
  haltdef
}


is better, because you now only escape if it's a query instead of escaping if it's a channel and ELSE use the query... you should use $target as the default action
Posted By: qwerty Re: a more uiniversal identifier than $chan - 14/10/03 11:32 AM
This way is no better either, since $target can be @#mirc for example. Many ircds support @#channel, +#channel or even @+#channel as targets and $target is filled with these. So why not let mirc do the job of extracting a channel name (if there is one) for you?
Code:
echo 14 $iif(#,#,$nick) ....
In a query/dcc chat you can use $nick
so, can we all agree that a single identifier that did the job regardless of the source would be a good idea?
Posted By: Doqnach Re: a more uiniversal identifier than $chan - 14/10/03 11:59 PM
dcc chat is =$nick , not $nick
Posted By: cold Re: a more uiniversal identifier than $chan - 15/10/03 06:14 AM
I agree. I find a little pointless to do this job myself.
© mIRC Discussion Forums