Is it possible for a macro to read from a text file?

Developer discussion regarding MapTool 1.4

Moderators: dorpond, trevor, Azhrei

Forum rules
Posting now open to all registered forum users.
Post Reply
taustinoc
Dragon
Posts: 516
Joined: Mon Aug 03, 2015 6:30 pm

Is it possible for a macro to read from a text file?

Post by taustinoc »

It would be most useful in setting up a large set of standardized NPCs and monsters as token files, but I see no evidence that it is possible (and I can see why it might not be).

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Is it possible for a macro to read from a text file?

Post by aliasmask »

I often put raw text in to a macro and read the text from that to parse through the info. Here's a code snippet to help:

Code: Select all

<!-- read in raw dialog -->
[H: EOL = decode("%0A")]
[H: buttonIndex = getMacroIndexes("rawDialog")]
[H: descriptions = json.fromList(getMacroCommand(buttonIndex),EOL)]
This puts each line of text in to an array field.

taustinoc
Dragon
Posts: 516
Joined: Mon Aug 03, 2015 6:30 pm

Re: Is it possible for a macro to read from a text file?

Post by taustinoc »

That would be about 99% as good. Thanks. Should have thought of it myself. Is there a limit on how much text one can paste in at a time? (I'm guessing at least 64k, which is way more than I'd ever need, but one never knows.)

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Is it possible for a macro to read from a text file?

Post by aliasmask »

I've done a full spell library of 1600 entries. You problem occurs when you loop more than 1000 times because there is a limit to the loops in MT. You can get fancy and exceed that, but the simple way is to process only 1000 things per loop at a time.

Post Reply

Return to “MapTool 1.4”