Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to pass prompt values?

Greetings gents,

So I am building a random loot generator. I want to call another generator (spell scroll) that I have created. The Spell Scroll generator has two prompts (Class and Level).

In my random loot generator is there a way to to call the spell scroll generator passing values for the prompts?

Here is my spell scroll code. So I am interested in calling @SpellProxy from the Random Loot Generator and being able to pass $prompt1 and $prompt2


Prompt: Choose a Level {Random|1|2|3|4|5|6|7|8|9}1 Prompt: Choose a Class {Random|Arcane|Artificer|Bard|Cleric|Druid|Paladin|Ranger|Warlock}Random Define: NumSpells=1 Define: PromptLevel={$prompt1} Define: PromptClass={$prompt2} Table: SpellProxy [@RandomSpell] Endtable: Table: RandomSpell Scroll of <i style="color:#ff0000">[!{$NumSpells} [@CasterClassTable] >> sort >> implode]</i> Endtable: Table: CasterClassTable [@Level][when]{$PromptClass}=Random[do][@RandomCasterClassTable][else]Spells {$PromptClass} Level {$SpellLevel}[end] Endtable: Table: RandomCasterClassTable [@Level]Spells [when]{$SpellLevel}>5[do][@ClassHigh][else][@ClassMid][end] Level {$SpellLevel} Endtable: Table: Level [when]{$PromptLevel}=Random[do]{SpellLevel=={1d9}}[else]{SpellLevel=={$PromptLevel}}[end] Endtable:

Comments

  • So, it's not recommended and there's no way to be sure it will work.

    The embedded generator that you call by means of a "Use" statement certainly will not prompt for user input, but you probably already know that.

    Putting variables based on direct user input, like {$prompt1}, into your "Use'd" generator is very risky, as those are internally defined variables. The best chance of it working is by using the "Define" command as you have done in your code example above.

    So, in general, try this in your Random Loot generator:

    use: nbos\Common\whatever-path-u-use\SpellScroll.ipt
    
    Prompt: Choose a Level {Random|1|2|3|4|5|6|7|8|9}Random
    Prompt: Choose a Class {Random|Arcane|Artificer|Bard|Cleric|Druid|Paladin|Ranger|Warlock}Random
    
    Define: PromptLevel={$prompt1}
    Define: PromptClass={$prompt2}
    
    [@SpellProxy]
    

    In the Spell Scroll generator, don't ask for prompts, just call the constant defined variables PromptLevel and PromptClass and hope that they carry over with defined values from the RandomLoot generator.

    If it doesn't work, I wouldn't spend too much time messing with it. I really believe that I read somewhere it's not a supported function to pass variable values from one generator into a second "Use'd" generator.

    For me, if the loot is really random, I'd just make a copy of your Spell Scroll generator, remove the user inputs all together in the new copy, and just let selection of level and class be determined randomly within the Copy Of Spell Scroll generator. Then you just call the table you want, and don't worry about passing variable values.

  • Thank you for this Levendor. This makes sense to pull the prompts specifically out of the original file and only have them in the generator themselves.

    This did seem to solve the problem actually.

  • Great. Please post you finished generator, if you are able to share. I'd like to see it & use it when you're done. Thanks

Leave a Comment