mIRC Home    About    Download    Register    News    Help

Print Thread
#236758 23/03/12 09:53 PM
Joined: Mar 2012
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2012
Posts: 7
okay, so I'm pretty much a novice in irc scripting but I need to know how to allow color and use spaces and nicks in the commands... I don't know if tokenizing helps at all or not but still I want to write a script that responds to:

?throw at <nick> (i.e. ?throw at randomnick)

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
You have two/three options if you want to accept colors within your matched text. You can use a regex to strip out the codes in the event header, use a wildcard (non-regex) event and strip the colors inside the event, or turn off color codes completely in mIRC. And if I understand correctly you want to allow for an arbitrary number of spaces between words? Tokenize will take care of that, or a \s+ in the regex.

Code:
on $*:text:/\?throw\s+at\s+(\S+)/S:#:{
  if ($regml(1) !ison #) return
  ;start here
}

on *:text:*:#:{
  tokenize 32 $strip($1-)
  if ($1-2 != ?throw at) || ($3 !ison #) return
  ;start here
}

Joined: Mar 2012
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2012
Posts: 7
so wait, tokenize allows spaces?? so I could put (after the tokenize line)
Code:
 If ($1 == ?Suit up) {... 
or does it need to be
Code:
 If ($1-2 != ?Suit up) {... 
???

Joined: Mar 2012
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2012
Posts: 7
oh and if I want to use a message how would I put in the nick that something was "thrown at," like this:
Code:
 msg $chan $nick threw a weapon at $3 
or do I have to include the !ison # part too?

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
The latter. Tokenization can allow spaces, but the tokenized data in $1- in an event or alias call is tokenized by spaces. You could retokenize by using:

/tokenize N $rawline

Where N is the ASCII value of some character (32 is space, for reference). Then $1- is filled with those tokens. Basically, mIRC calls /tokenize 32 $rawline internally before your event runs. Notice that the script above does this retokenization by spaces in order to strip colour codes from $1-.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Mar 2012
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2012
Posts: 7
do you mean the latter on both questions or just the first one bc i still need to know how to put both the nick that threw the object and the nick the object was thrown at

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
$nick refers to the person who triggered the event, $3 refers to the third word in their text, in this case it is treated as the target nick.

Joined: Mar 2012
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2012
Posts: 7
Thank you guys! Can you also tell me how to decrease a value like:
Code:
 set %Darts1 5 
so that once the "throw at" command is triggered it sets it to 4 then 3 and so on without typing
Code:
if (%Darts1 == 5) set %Darts1 4
if (%Darts1 == 4) set %Darts1 3 
??

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Try referencing the manual before coming here for help. Look up /set (which you are already using) and you'll find /inc and /dec a few lines down. Searching the help for "decrease" also brings up the appropriate command.

Joined: Mar 2012
Posts: 7
R
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Mar 2012
Posts: 7
I'm sorry, you're right I should of looked in the help file first (Found it!!). Thanks. P.s. I may continue this thread in the future when I need help and can't find (or understand) what I need from the help file.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
It is usually better to start a new thread for each new problem. By keeping each issue in its own thread, it makes it easier for anyone trying to help you and it also makes it easier for anyone searching the forum for support. Consider if you have a 4 page thread where the question in post 1 is answered by post 4. Someone might still be replying with a solution on page 4 even though you already solved that problem and are talking about another problem.

We also don't care if there are many different threads from one person... as long as the threads are for support and not spamming, of course.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard