Table parameters being used from one table to the next

So I have set up two tables to use the passing of parameters. One table I have created a hack for basically handling an variable number of parameters, (array of data). However what I am noticing is that if a table before it has two parameters the second parameter will be sent to the second table.

I imagine there is a few ways to handle this. One if there is an actual way to handle a variable number of parameters. The other would be to reset the table parameters.

So in the following, first and second line work great. As expected. First line will loop thru and show three different values, second one will loop thru once and only show one value.

On the third line, the call to @GemTypes works as expected, but them @Coins acts as if 2 parameters have been passed and shows a second line with the value of 10. (The second parameter for the @GemTypes table call)

What am I missing here?

Table: Individual 0-4
25: [@Coins with {1d4}{g},{5d6}{s},{5d10}{c}]
20: [@Coins with {3d6}{g}]
5: [@GemTypes with {1d2}, 10] [@Coins with {3d6}{s}]
Endtable:

Table: GemTypes
[@{$1} Gems {$2} >> implode </li><li>]</li>
{$1} [@Gems {$2} >> implode </li><li>]</li>
Endtable:

Table: Coins
Set:
[when] {$1} [do] <li><i style="color:#ccac00">{$1}</i></li> [end][when] {$2} [do] <li><i style="color:#ccac00">{$2}</i></li> [end][when] {$3} [do] <li><i style="color:#ccac00">{$3}</i></li> [end][when] {$4} [do] <li><i style="color:#ccac00">{$4}</i></li> [end]
Endtable:

Comments

  • Can you post a more complete set of code? What you posted is missing the @Gems table. I guessed at what that should look like, and got it to stop returning the extra line of 10 for the gold coins call, but I'm not sure what the [@GemTypes with {1d2}, 10] is trying to do.

  • So basically the call

    [@GemTypes with {1d2}, 10]

    Table: GemTypes
    [@{$1} Gems {$2} >> implode </li><li>]</li>
    {$1} [@Gems {$2} >> implode </li><li>]</li>
    Endtable:
    

    Will pass 1d2 as the $1 variable on the on the @Gems 10 table. The $2 passing the 10 to pick the right Gems table. I have other Gems table values.

    Table: Gems 10
    [@10gpGemstone] [@Value10 with {gem10roll}]
    Endtable:
    
    Table: 10gpGemstone
    Alabaster <i>([|white-|cream-]colored stone)</i>
    Azurite <i>(opaque mottled deep blue)</i>
    Blue quartz <i>(transparent pale blue)</i>
    Hematite <i>(opaque gray-black)</i>
    Lapis lazuli <i>(opaque light and dark blue with yellow flecks)</i>
    Malachite <i>(opaque striated light and dark green)</i>
    Obsidian <i>(opaque black)</i>
    Rhodochrosite <i>(opaque light pink)</i>
    Tiger eye <i>(translucent brown with golden center)</i>
    Turquoise <i>(opaque light blue-green)</i>
    Pearl, irregular freshwater <i>(Freshwater pearls tend to be irregular in shape.)</i>
    Pyrite <i>(yellowish fools' gold)</i>
    Quartz, rock crystal <i>(nearly clear form of quartz)</i>
    Shell <i>(shells come in mny forms)</i>
    Endtable:
    
    Table: Value10
    (<i style="color:#ccac00">{gem10roll} galifars </i>)
    Endtable:
    
  • edited September 2018

    OK... here's what's happening. @GemTypes with {1d2} 10 is setting {$2} to a value of 10 until some other parameter sets {$2} to a new value, and I can't figure out how to "unset" {$2} to null before running the call on the @Coins table.

    So, instead of unsetting {$2} to null, I reset to a value of 0 and tweak the when condition in @Coins to do nothing if {$2}=0.

    I also need to set {$2}=0 in the second table call where @Coins only has a single parameter specified (gold only). Otherwise, I get a blank line if @Coins is called with only one parameter.

    Here's the code. I think you will see how it works once you run it.

    Table: Individual 0-4
    25: [@Coins with {1d4}{g},{5d6}{s},{5d10}{c}]
    20: [@Coins with {3d6}{g},0]
    5: [@GemTypes with {[1d2]},10] [@Coins with {3d6}{s},0]
    Endtable:
    
    Table: GemTypes
    <li>[@{$1} Gems {$2} >> implode </li><li>]</li>
    <li>{$1} [@Gems {$2} >> implode </li><li>]</li>
    Endtable:
    
    Table: Coins    
    [when] {$1} [do] <li><i style="color:#ccac00">{$1}</i></li> [end][when] {$2} <> 0 [do] <li><i style="color:#ccac00">{$2}</i></li> [end][when] {$3} [do] <li><i style="color:#ccac00">{$3}</i></li> [end][when] {$4} [do] <li><i style="color:#ccac00">{$4}</i></li> [end]
    Endtable:
    

    Here's the edited portions in bold-italic (3 locations of edits to your original code):

    Table: Individual 0-4
    25: [@Coins with {1d4}{g},{5d6}{s},{5d10}{c}]
    20: [@Coins with {3d6}{g},0]
    5: [@GemTypes with {[1d2]},10] [@Coins with {3d6}{s},0]
    Endtable:

    Table: GemTypes
    [@{$1} Gems {$2} >> implode

    ]
    {$1} [@Gems {$2} >> implode ]
    Endtable:

    Table: Coins
    [when] {$1} [do]

    {$1} [end][when] {$2} <> 0 [do] {$2} [end][when] {$3} [do] {$3} [end][when] {$4} [do] {$4} [end]
    Endtable:

Leave a Comment