Fix value passed to lookup table?

Is it possible to use a lookup table and have the Roll: xxx value passed from a variable instead of a die roll?

Or is it possible to modify the Roll: xxx for a lookup table (e.g. Roll: 1d100 + {$1} )?

Comments

  • Yes. In the code below, there is a variable called SpellLevel. It's value basically set by a user prompt, but it could really be set by anything in the generator, but it better be an integer!

    Then I call for a {1d{{SpellLevel}+1}-1} which is 1 roll of a (SpellLevel plus 1) sided die minus 1.

    So say that SpellLevel was set to 5. It would call for a 1d{5+1} - 1, that is a 1d6 - 1, with integer results from 0 to 5. In this generator, it's used to generate a spell from level 0 (cantrip) to level 5 for a scroll of magic level 5.

    You would use syntax more like Roll: 1d{100+{$var}}

    And again, $var better have an established integer value before the die roll is called.

    ; Spell Level Test.ipt
    ; created 5/24/2018 10:12:37 AM
    
    Prompt: Spell Level {Random|1|2|3|4|5|6|7|8|9} Random
    
    Define:PromptLevel={$Prompt1}
    
    Table: SpellProxy
    [@Level][when]{$PromptLevel}>5 [do]{CasterClass="[@ClassHigh]"}[else]{CasterClass="[@ClassMid]"}[end] Scroll Level: {$SpellLevel}\n [@{1d4+(floor({SpellLevel}/3))} RandomSpell >> sort >> implode </br>]
    
    Table: Level
    [when]{$PromptLevel}=Random[do]{SpellLevel=={1d10-1}}[else]{SpellLevel==PromptLevel}[end]
    
    Table: RandomSpell
    Level {1d{{SpellLevel}+1}-1} - {floor({{1d4}+({SpellLevel}/3)})} Spells
    #Level 2 - {floor({{1d4}+({SpellLevel}/3)})} Spells
    #Level 3 - {floor({{1d4}+({SpellLevel}/3)})} Spells
    #Level 4 - {floor({{1d3}+({SpellLevel}/4)})} Spells
    #Level 5 - {floor({{1d3}+({SpellLevel}/4)})} Spells
    #Level 6 - {floor({{1d3}+({SpellLevel}/4)})} Spells
    #Level 7 - {floor({{1d2}+({SpellLevel}/5)})} Spells
    #Level 8 - {floor({{1d2}+({SpellLevel}/5)})} Spells
    #Level 9 - {floor({{1d2}+({SpellLevel}/5)})} Spells
    
    Table: ClassMid
    Roll: 1d120
    01-10:Druid 
    11-25:Cleric 
    26-45:Artificer 
    46-75:Arcane 
    76-90:Bard 
    91-100:Warlock 
    101-110:Paladin 
    111-120:Ranger
    
    Table: ClassHigh
    Roll: 1d80
    01-10:Druid 
    11-25:Cleric 
    26-55:Arcane 
    56-70:Bard 
    71-80:Warlock
    
  • Maybe you were asking something more basic, like can I have a lookup table without a Roll: call. Yes, I use it often. Try calling the table like this:

    [#{$var} TableName]

    It sends the value of {$var} to the table, and if the table is defined as a lookup table, then it uses that value to lookup a result.

    In the generator below, it looks like:

    [#{1d28+90} CmdrTitle]

    Which sends a value of 91 to 118 to table CmdrTitle, which effectively shifts the result to the higher end of the table, resulting in a much higher chance to have a noble or royal title.

    Now, you can combine that with my previous post and make the 28 a variable, or the 90 a variable, or both. I suppose you could maybe even make the 1 a variable, if the number of dice rolled is determined by something else in your generator.

    Here's a generator that I trimmed down from a much bigger one to demonstrate. In this one, if the knight's rank is low, like a Bachelor, then he rolls 1d104 on the noble title table, meaning he will be likely titled "Sir", and at best be titled "Baron". Whereas a Knight Commander sends a 1d28+90 to the table, making him more likely than not to have a noble title (must roll 11+ on the 1d28 to be a Baronnet or better, and yes, Baronnet is not technically a noble) and at best he may be a Crown Prince (rolls a 28 on the 1d28).

    ; Test table roll.ipt
    ; created 6/9/2018 10:35:58 PM
    Knight's Troop.ipt
    ; created 11/9/2017 3:02:08 PM
    
    use: nbos\names\Human.ipt
    
    Prompt: Troop Size {Patrol|Company|Regiment|Army} Company
    
    Table: Main
    [#{$prompt1} Description]\n\n[#{$prompt1} Leader]
    
    Table: Leader
    Type: Dictionary
    Patrol: [#{1d60} PatrolRank]
    Company: [#{1d17+17} CoRank]
    Regiment: [#{1d25+33} RegRank]
    Army: Army of [@Army]
    
    Table: Army
    [#{1d10+109} CmdrTitle] [@MasterHumanName] of [@MasterHumanName]
    
    Table: Description
    Type: Dictionary
    Patrol: A patrol consisting of a knight and his personal retainers.
    Company: A company consisting of a detachment of one or more knights from a nobleman's regiment.
    Regiment: A regiment consisting of a Knight Commander and all troops serving a nobleman.
    Army: A major war band, temporarily organized for a campaign, consisting the forces of a major nobleman and his liegemen. 
    
    Table: PatrolRank
    Type: Lookup
    1-38: Knight Bachelor [#{1d104} CmdrTitle] [@MasterHumanName]'s {$Prompt1}
    39: Knight Banneret [#{1d88+20} CmdrTitle] [@MasterHumanName]'s {$Prompt1}
    40-56: Knight Attendant [#{1d88+20} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    57: Knight Companion [#{1d38+80} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    58-59: Knight Champion [#{1d90+20} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    60: Knight Commander [#{1d28+90} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    
    Table: CoRank
    Type: Lookup
    1-16: Knight Bachelor [#{1d104} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    17: Knight Banneret [#{1d88+20} CmdrTitle] [@MasterHumanName]'s {$Prompt1}        
    18-30: Knight Attendant [#{1d88+20} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    31: Knight Companion [#{1d38+80} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    32-33: Knight Champion [#{1d90+20} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    34-55: Knight Commander [#{1d28+90} CmdrTitle] [@MasterHumanName]'s {$Prompt1}
    56-60: Grand Knight Commander [#{1d16+103} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    
    Table: RegRank
    Type: Lookup
    1-16: Knight Bachelor [#{1d104} CmdrTitle] [@MasterHumanName]'s {$Prompt1}
    17: Knight Banneret [#{1d88+20} CmdrTitle] [@MasterHumanName]'s {$Prompt1}     
    18-30: Knight Attendant [#{1d88+20} CmdrTitle] [@MasterHumanName]'s {$Prompt1}
    31: Knight Companion [#{1d38+80} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    32-33: Knight Champion [#{1d90+20} CmdrTitle] [@MasterHumanName]'s {$Prompt1} 
    34-55: Knight Commander [#{1d28+90} CmdrTitle] [@MasterHumanName]'s {$Prompt1}
    56-60: Grand Knight Commander [#{1d16+103} CmdrTitle] [@MasterHumanName]'s {$Prompt1}
    
    Table: CmdrTitle
    Type: Lookup
    1 - 100: Sir 
    101 - 102: Baronnet 
    103 - 106: Baron 
    107: Archbaron 
    108: Viscount 
    109 - 111: Count 
    112: Marquis 
    113 - 114: Duke 
    115: Grand Duke 
    116: Archduke 
    117: Prince 
    118: Crown Prince
    119: King 
    
  • Thank you! Example #2 was almost exactly what I needed.

Leave a Comment