Forums > MaxMSP

Reading text data from a file to trigger bangs?

February 9, 2009 | 12:39 am

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


February 9, 2009 | 1:40 am

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


February 9, 2009 | 1:44 am

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


February 9, 2009 | 12:55 pm

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.


February 9, 2009 | 1:26 pm

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…?


February 9, 2009 | 1:31 pm

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


February 9, 2009 | 1:52 pm

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


May 7, 2011 | 5:16 am

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).


Viewing 8 posts - 1 through 8 (of 8 total)