On input

From Scriptwiki
Revision as of 19:22, 19 November 2005 by Doomie (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The on INPUT event triggers when you enter text in an editbox and press enter.

on <level>:INPUT:<*#?=!@>:<commands>

Read Limiting Access to get more information about the prefixes and suffixes (*#?=!@).

Note that this event has no matchtext-field. You have to use if-statements to make more restrictions.

Example

The following example will connumerate your written characters and words.

; Whenever you say something, this even will trigger.
on *:INPUT:*: {
 ; set variable %allchars to the total amount of characters you have written.
 set %allchars $calc(%allchars + $len($1-))
 ; set variable %allwords to the total amounts of words you have written. 
 set %allwords $calc(%allwords + $numtok($1-,32))
}

The next, more complex, example will replace all "moo"'s with "moo00oo00" in your text.

on *:INPUT:*: {
  ;nothing will change if you press control + enter or the first character is the command prefix     
  ;character you have specified in your mIRC options (usually "/").
  if (($ctrlenter) || ($left($1,1) == $readini(mirc.ini,text,commandchar))) { return }
  else {
   ; send the "new" text to the channel (but hidden)
   .msg $active $replace($1-,moo,moo00oo00)
   ; echo the "new" text in your current window (as it's the window you have just typed it)
   echo -t $active < $+ $me $+ > $replace($1-,moo,moo00oo00)
   ; stop the usual output
   haltdef
  }
} 
   

See Also

To trigger on text from other users, you have to use the On Text Event.