Reading text data from a file to trigger bangs?

Feb 9, 2009 at 12:39am

Reading text data from a file to trigger bangs?

My question is as follows:
I want max/msp to read information from a log file which Quake prints as events occur in the game. the log file is a text file. max/msp needs to be able discern useful phrases from this, and ignore irrelevant information.

Here’s an example:

You receive 25 health
You get 2 rockets
You got the rockets
You got the nailgun
You got the nails

so, perhaps i want max/msp to send a bang when the phrase “You get 2 rockets” occurs, but ignore the rest. how can I do this?

thanks for any tips in advance

#42192
Feb 9, 2009 at 1:40am

to read in the text file you use [text]
to read out [text] you send it “line $1″
to compare you use this:

– Pasted Max Patch, click to expand. –

p

Jon Weinel wrote:
> My question is as follows:
> I want max/msp to read information from a log file which Quake prints as events occur in the game. the log file is a text file. max/msp needs to be able discern useful phrases from this, and ignore irrelevant information.
>
> Here’s an example:
>
> You receive 25 health
> You get 2 rockets
> You got the rockets
> You got the nailgun
> You got the nails
>
> so, perhaps i want max/msp to send a bang when the phrase “You get 2 rockets” occurs, but ignore the rest. how can I do this?
>
> thanks for any tips in advance
>
>
>
>

http://pure.test.at
http://www.myspace.com/pvre
http://www.heartchamberorchestra.org

http://www.trblnc.org

#150928
Feb 9, 2009 at 1:44am

forget the [tosymbol] in my example. they arent necessary

p

http://pure.test.at
http://www.myspace.com/pvre
http://www.heartchamberorchestra.org

http://www.trblnc.org

#150929
Feb 9, 2009 at 12:55pm

Quote: pure wrote on Sun, 08 February 2009 18:40
—————————————————-
> to compare you use this:
>
>

– Pasted Max Patch, click to expand. –

erm, is that a patch? i can’t seem to open it..?

the text option appears to be the ticket anyway, i’ve got it reading specific lines out into a message box.. so i just need some sort of comparing or route-type object to deal with the phrases.

the next question will be, since the log file is updated contrantly as events occur in the game, how to get it to read the last line, and perhaps re-read the document each time it changes. so i can get new lines to display accurately and quickly as they occur, without having to make max read the whole document repeatedly constantly.

#150930
Feb 9, 2009 at 1:26pm

possibly this is covered in your example.. but how do you get phrases with multiple words to register as a single message?

So I could route “You got armor”, but this doesn’t seem to work? I could only route the “You” part…?

#150931
Feb 9, 2009 at 1:31pm

Jon Weinel wrote:
> erm, is that a patch? i can’t seem to open it..?
yeah but its max5 only.
> the text option appears to be the ticket anyway, i’ve got it reading specific lines out into a message box.. so i just need some sort of comparing or route-type object to deal with the phrases.
>
check the screenshot i attached to rebuild it in max4
> the next question will be, since the log file is updated contrantly as events occur in the game, how to get it to read the last line, and perhaps re-read the document each time it changes.
[filewatch]
> so i can get new lines to display accurately and quickly as they occur, without having to make max read the whole document repeatedly constantly
reading in such tiny textfiles should be no problem at all if you can
run quake at the same time.

p

http://pure.test.at
http://www.myspace.com/pvre
http://www.heartchamberorchestra.org

http://www.trblnc.org

#150932
Feb 9, 2009 at 1:52pm

okay i’ve got it. thanks for your help, looks like it’s going to work a treat!

#150933
May 7, 2011 at 5:16am

Hate to open up an old thread, but I thought it helpful to know:

the object filewatch will bang every time a file is changed. It’s awesome, and would mean you wouldn’t have to poll constantly (if for some reason you didn’t want to do that).

#150934

You must be logged in to reply to this topic.