Snippet to append the last users nickname to your edit box by hitting tab at the beginning or after a space. Also, if the last word is the last users nickname, it will be changed to the channel name.
Examples:
"" >> [TAB] >> "LastUsersNick"
"Hi " >> [TAB] >> "Hi LastUsersNick"
"Hi LastUsersNick" >> [TAB] >> "Hi #CurrentChannel"
Very nice when answering questions in a busy channel.
on *:TABCOMP:#:{
var %lastnick = $hget(lastnick,$cid $+ $chan)
if (($regex(edit,$editbox($active),/(^|^.* )( $+ $chan $+ $chr(124) $+ %lastnick $+ )?$/)) && ($1- == $regsubex($editbox($active),/(^ +| +$)/g,))) {
if ($regml(edit,2) == %lastnick) editbox -a $regml(edit,1) $+ $chan
else editbox -a $regml(edit,1) $+ $iif(%lastnick, $v1, $chan)
halt
}
}
on *:TEXT:*:#:{ hadd -m lastnick $cid $+ $chan $nick }
on *:ACTION:*:#:{ hadd -m lastnick $cid $+ $chan $nick }
on *:NOTICE:*:#:{ hadd -m lastnick $cid $+ $chan $nick }
Pardon me for hijacking your thread for something off-topic, Thelmrac.
Matcou, I meant other people but didn't aim for a perticular individual. :p
As we begin to learn more about MSL, we'll gradually have more clearer understanding and distinction toward what other people have to say and judge if he or she gives us a factual, senseful answer. Oftentimes beginners and novice users alike don't have a clue and can easily be ill-informed or misinformed. Then before we know it, it passes down from another new user to the other...the consequence is going to be dire.
I got it working (for the most part), without needing to use the dirty variable hack.
ah, quite right, since the first condition implies the second.
It still takes out any extra spaces in the edit box string
yes, that's very unfortunate and entirely unavoidable without a DLL. a while ago i abandoned a sophisticated identifier completion script i was making because of it :( bear in mind you can add a single trailing space to the editbox with /editbox's -p switch.
I got it working (for the most part), without needing to use the dirty variable hack. Basically I make sure $1- and the edit box are the same. If they are, that means TAB isn't trying to auto complete.
The Downfalls:
It still takes out any extra spaces in the edit box string
If you are use the normal auto complete on a nickname and its the only auto complete match, and its the last nickname seen, it will toggle between that nickname and the channel if you hit tab again. (not a huge deal)
But now you can tab through multiple normal auto completes and it won't change to the channel name if one of the nicks is the last nickname seen.
good point
you can compare $1- to $editbox($active):
on *:tabcomp:#:{
if (!%tabcomp) || ($1- == $gettok($editbox($active), 1-, 32)) {
; your script
}
unset %tabcomp
}
now, it's still possible for the two to be equal if, for example, i type 'j' then press tab to get 'jaytea' and tab again. if there's no other 'j*' nicks in the channel, your script will fire. the only way to prevent this is by storing data over successive calls to on TABCOMP, since there is no way to access the history of completions ;(
Actually, it seems to break with the added ^.
ah, that's interesting. apparently the difference between including the ^ prefix is that on ^TABCOMP will only trigger if there is a completion to be made. without the ^ prefix, it will trigger on any tab press, which is what this snippet relies on.
about preserving cycling, given that your script only concerns itself with instances where there is nothing to be completed, you can use the fact that on ^TABCOMP triggers only when there IS something to be completed:
on ^*:tabcomp:#:{ set %tabcomp 1 }
on *:tabcomp:#:{
if (!%tabcomp) {
; your script
}
unset %tabcomp
}
a bit hacky but i can't think of a better way ;P