mIRC Home    About    Download    Register    News    Help

Print Thread
Checking a text event against a variable #219570 22/03/10 03:10 AM
Joined: Mar 2010
Posts: 2
X
Xelah Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
X
Joined: Mar 2010
Posts: 2
This is for a text based game I've been playing for years and wanted to create a bot to help my team. I've got it working as is, but every time the game is over, I have to recode parts of it and it's gotten very tedious as the bot has gotten much more complicated.

Every team in the game has a value that is attached to anything that affects them and my bot watches for our value and the values of our allies when the irc newsfeed posts what is going on in the game.

My event currently looks like this:
Code:
on 1:TEXT:*CM*[DKNIGHTS]*[*:#:{


[DKNIGHTS] is the value associated with my team and my bot lets us know we've just attacked someone. The problem is that [DKNIGHTS] is not always assigned to us, and the same goes for the tags assigned to our friends. The second [ is there to check to see if we are first in the line of text or second. If there isn't a [ after our tag, then it is us who have just been attacked.

I wanted to use ISIN to watch all newsfeed items that indicate an attack, but that doesn't allow me to find out what order the brackets are in and it can't tell us if we are attacking or being attacked. There is a lot of functionally meaningless gibberish between the brackets and I can't try to include that in the isin.


To try to curb this a little, I wrote a small script that lets me assign our value to a variable called %ourtag

I tried running it through like this:
Code:
on 1:TEXT:*CM*%ourtag*[*:#:{


But when I do that, mIRC reads %ourtag literally instead of the value assigned to %ourtag. Adding spaces before and after %ourtag did not help. The only way I can even get the bot to read the value is to make it not look for any other text with it.

Code:
on 1:TEXT:%ourtag:#:{


The newsfeed will never just spit out our tag, and if it did, it would be the most useless bit of info it has ever told us.

Basically, I'm looking for a way to have the script tell me when %ourtag appears in a line of text with a bracket after it and when certain letters appear at the beginning (the letters tell us what kind of attack it is and whether or not we need to worry).

Any help would be greatly appreciated.

Re: Checking a text event against a variable [Re: Xelah] #219571 22/03/10 03:20 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Try
Code:
on 1:TEXT:$($+(*CM*,%ourtag,*[*)):#:{
Type /help $(...) for more information.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: Checking a text event against a variable [Re: qwerty] #219572 22/03/10 03:32 AM
Joined: Mar 2010
Posts: 2
X
Xelah Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
X
Joined: Mar 2010
Posts: 2
wow, that was easy.

On behalf of my team, Epic Thanks.

Re: Checking a text event against a variable [Re: Xelah] #219573 22/03/10 03:48 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
You can also use regex, but is a bit complicated. This strips control codes and will match %ourtag:
Code:
on $1:TEXT:$(/(\52CM\52\133\Q $+ %ourtag $+ \E\135\52\133\52)/iS):#: {