Nested tables

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Hypatia
Cave Troll
Posts: 29
Joined: Sun Oct 21, 2012 5:30 am

Nested tables

Post by Hypatia »

Something strange has happened to my nested tables.
They have stopped working

The macro looks up the table alright but if it is then instructed to go on to a further table it will not.

For example the table entry /tbl DWARVES just returns /tbl DWARVES and doesn't look it up on the DWARVES table.

I was wondering if there is some preference I have inadvertantly changed.

Any suggestions?

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

Re: Nested tables

Post by aliasmask »

I just tested it out and it seems to work. Are the table names spelled correctly and with the right case (case sensitive). Also, does the roll field in both tables have values and is the range of values correct (6 items labelled 1-6 where Roll is 1d6).

Hypatia
Cave Troll
Posts: 29
Joined: Sun Oct 21, 2012 5:30 am

Re: Nested tables

Post by Hypatia »

Absolutely. All case correct, all values accounted for. As i said, they have been working and I haven't changed them.In addition I have tried with a test table and the result is the same. It just prints out /tbl DWARVES without going there.

The macro is

[r:tbl("RACE")]


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

Re: Nested tables

Post by aliasmask »

Oh, you're using a slash command in a macro. That works in chat, but not with macros. You can do it this way.

Code: Select all

[r: evalMacro(tbl("RACE"))]
where the Dwarves entry is

Code: Select all

[r: tbl("DWARVES")]
or you can put tbl("DWARVES") and use eval instead of evalMacro. Typing /tbl RACE works only as a chat command.

Hypatia
Cave Troll
Posts: 29
Joined: Sun Oct 21, 2012 5:30 am

Re: Nested tables

Post by Hypatia »

You have totally and utterly solved it for me.
Ta

monstro44122
Kobold
Posts: 6
Joined: Thu Aug 03, 2017 12:21 pm

Re: Nested tables

Post by monstro44122 »

This problem is very similar to my own so I'm hoping to restart this thread. If that can't be done... well, I'll post elsewhere.

Here's the problem. What if the nested tables are multiple and variable levels deep?

So, I have a macro that "gets treasure". Gets Treasure is a table of tables that, you guessed it, calls a table of tables, which in turn is likely to call a table of tables...

GetsTreasure-->SomePotions-->AttackPotionsTables-->SpecificAttackPotion

of course, it could call....

GetsTreasure-->AmmountOfGold-->SpecificAmmountOfGold

Let's say that you have a Macro that rolls on the table "GetsTreasure". How would I write the macroeval macro so as to continue to pull up the table call commands through the nesting? Or does Macroeval do that automatically. In the previous example, if "dwarves" was a table, would the Macroeval go into that table as well?

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Nested tables

Post by wolph42 »

you do that by cramming this:

[r: evalMacro(tbl("RACE"))]

inside the table so in your example (a bit shorter)

GetsTreasure (this is the macro) -->SomePotions (this is a table)-->AttackPotionsTables (this is the final table)

then:
GetsTreasure contains:
[r: evalMacro(tbl("SomePotions "))]
in SomePotions
you have the entry
[r: evalMacro(tbl("AttackPotionsTables "))]
and in
AttackPotionsTables
you have:
"Strength + 1" (or in case of you full example: [r: evalMacro(tbl("SpecificAttackPotion"))] )

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

Re: Nested tables

Post by aliasmask »

There are several ways to do this.

One way only using MT table is to do an evalMacro at the first level

Code: Select all

[r: evalMacro(tbl("Treasure"))]
Then for your table entries you can put in the final value or another evalMacro call. For example,

Code: Select all

"Treasure" Table
1 - [r: evalMacro(tbl("Potion"))]
2 - [r: evalMacro(tbl("Gold"))]

"Potion" Table
1 - [r: evalMacro(tbl("AttackPotions"))]
2 - [r: evalMacro(tbl("HealingPotions"))]

"AttackPotions" Table
1 - [r: 1d8 + " holy water damage"]
2 - [r: 1d6 + " fire damage"]

"HealingPotions" Table
1 - [r: 1d8+1 " healing"]
2 - [r: 2d8+3 " healing"]
3 - "No Healing"

"Gold" Table
1 - [r: 2d10 + " gold"]
2 - [r: 4d20 + " gold"] 

monstro44122
Kobold
Posts: 6
Joined: Thu Aug 03, 2017 12:21 pm

Re: Nested tables

Post by monstro44122 »

Hmmm...

I think there's a legacy wiki out there. I swear that I read I couldn't put roll options or macro calls inside of tables. That would certainly make a lot of this easier.

I'm going to give your suggestions a shot and see how they work. Thanks for all the help.

***Okay, I entered the macro call in the table as:
[r: evalMacro(tbl("AttackPotion1"))] where AttackPotion1 is NOT a table of tables.

and it kicked that exact phrase out to the chat window. In other words, it didn't roll on AttackPotion1. It just wrote [r: evalMacro(tbl("AttackPotion1"))] in the chat window. It wrote it in red, if that makes sense.

Is there some option I should turn on or off?

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

Re: Nested tables

Post by aliasmask »

If you're not going to specify the field or random number make sure your table has the correct roll in it for your fields. Also, you're evaluating the values in your potion table as a macro, so make sure it's formatted correctly. Also, table names are case sensitive, so make sure that's correct.

monstro44122
Kobold
Posts: 6
Joined: Thu Aug 03, 2017 12:21 pm

Re: Nested tables

Post by monstro44122 »

I'm pretty sure all of that's right...
chat.jpg
chat.jpg (60.24 KiB) Viewed 1056 times
Table1.jpg
Table1.jpg (53.03 KiB) Viewed 1056 times

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

Re: Nested tables

Post by aliasmask »

I've tested this on my machine so I know it works, so it's probably your data or calling macro. I too at first was doing the calls incorrectly and it would just give me the text of the macro code. This would probably go faster if I were to just log on to your server and take a look. If you want to arrange a time for this we can try and meet up. PM me with any details.

monstro44122
Kobold
Posts: 6
Joined: Thu Aug 03, 2017 12:21 pm

Re: Nested tables

Post by monstro44122 »

I've.... no idea how to do that. Sorry, I have an advanced degree in English. Computers do...well what they're doing with me right now. I could attach the campaign file. It basically has one token, 3 tables, and two macros on it. Would that work?

Mostly though, I don't want someone to "fix" my code. I have hundreds of these tables to enter, and I don't want to be on here for every one of them, so I'd really just like to know how it works. So, if you see what I'm doing wrong or where I'm going zig when I should be zagging, I'd appreciate the head's up.

In any case, I've attached the campaign file.
Attachments
Encounter Design.cmpgn
(25.53 KiB) Downloaded 30 times

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

Re: Nested tables

Post by aliasmask »

I'll take a look at your campaign, but if you haven't already entered all your tables I may have a better solution for you. One that makes dealing with your data easier. Personally, I don't use the MT tables and just create data structures with all my data.

*edit* after a quick look all you need to do to call the table is what I posted above.

Code: Select all

[r: evalMacro(tbl("AttackPotionsFork"))]
Your potiontype table will need to be of a similar format as the others and use a call similar to the one above.

Post Reply

Return to “MapTool”