Reading text data from a file to trigger bangs?

genfu's icon

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

pure's icon

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

Max Patch
Copy patch and select New From Clipboard in Max.

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

--

pure's icon
genfu's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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

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.

genfu's icon

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

pure's icon

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

--

genfu's icon

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

Samueled's icon

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