Getting Table Values for Use in a List?

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
User avatar
elaxter
Kobold
Posts: 8
Joined: Thu Jul 20, 2017 7:27 pm

Getting Table Values for Use in a List?

Post by elaxter »

I'm making a simple macro that puts a frame up and displays a handout. The handout images are stored in a table, like so:
Image

Currently in my macro, I put the line

Code: Select all

[H:handOut="range,damage"]
for use in the following line:

Code: Select all

[H: status=input("image|"+handOut+"|Pick a handout to display|LIST|SELECT=0", ....
(selecting "range" in the drop down outputs 0, selecting "damage" outputs 1, and so on) which then concludes with

Code: Select all

<img src='[r: tblImage("hand",image,picSize)]'></img>
It gets the job done well enough, but if I want a new handout, I have to stick its name onto the end of that first line for it to show up as a valid input, in addition to adding it to the table, and make sure it correlates to the appropriate range.

Is there a way I can have the input function use the list of values from the table automatically, so I don't have to edit the macro each time I add something new to the table?

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

Re: Getting Table Values for Use in a List?

Post by aliasmask »

You'll have to store the table range somewhere since MT tables don't do it for you. This could be stored in a property on a lib token or in the table at the 0 range. For example,

Code: Select all

0     index     {1:"range",2:"damage"}
1     range     [pic]
2     damage    [pic]
You would then read in the 0 range to get the other items in table. You can then use the table functions to add new items and update the 0 range variable holding the range information.

Post Reply

Return to “Macros”