Need help with variables and conditionals

Forgive the possibly dumb question, but I've been slamming my head against this for a week now.
I'm trying to make IPP generate 2 rolls from the same table, then if the first and second roll are the same, replace the second with a different value.
here is my test code
Set: B=[@Roll&;#93;
Set: A=[@Roll&;#93;
[when] {$A} = {$B} [do] [B==Carter] [end]
Table: MyTable
{$A} {$B}
Table: Roll
Allen
Bradley

and here are the only unique outputs
Allen Allen
Allen Bradley
Bradley Allen
Bradley Bradley

Never Allen Carter or Bradley Carter. I've read and re-read the help files on variables and conditionals so much that they've lost all their meaning. I'm sure this is not an impossible task, but I'm stumped. I've imagined a couple of possible workarounds, but I really want to learn how to do variables and conditionals right.
Thanks in advance!
-Cliffy

Comments

  • I think you just want a deck pick. See the write up in the help file.
    Table: Main
    [!MyName] [!MyName]
    
    Table: MyName
    Allen
    Bradley
    Carter
    
  • Sorry, I think that my example code muddied the problem. Allen, Bradley, and Carter were supposed to be stand-ins for A, B, and C. I'll explain the actual context this time.
    The generator is for Gamma World 2010 characters. The way you make a character is to roll for a primary and secondary origin, both from the same table. If you roll the same entry for both, then your secondary becomes "Engineered Human" instead (this is the only way to get the engineered human origin).

    The origin table has 20 entries (which is why I truncated the example), so when I run the genny I get a lot of "Android Cockroach" and "Felinoid Speedster", but every now and then I get "Yeti Yeti". Engineered human never occurs.

    Here is the actual code
    Set: Primary=[@Origin&;#93;
    Set: Secondary=[@Origin&;#93;
    [when] {$Primary} = {$Secondary} [do] [Secondary==Engineered Human] [end]
    Table: Simple Gamma World Character
    {$Primary} {$Secondary}
    Table: Origin
    Android
    Cockroach
    Doppleganger
    Electrokinetic
    Empath
    Felinoid
    Giant
    Gravity Controller
    Hawkoid
    Hypercognitive
    Mind Breaker
    Mind Coercer
    Plant
    Pyrokinetic
    Radioactive
    Rat Swarm
    Seismic
    Speedster
    Telekinetic
    Yeti
    EndTable:
    

    Sorry for the confusion, but hopefully the problem makes more sense now.
  • The problem is you are putting the [when] on its own line, so it will get ignored. A [when] is part of an expression. So you need to put it someplace where it will be evaluated - in this case, in the Set statement. Use a temporary variable to hold the value you want to check:
    Table: Main
    Set: Primary=[@Origin&;#93;
    Set: a=[@Origin&;#93;
    Set: Secondary=[when] {$a} = {$Primary} [do]Engineered Human[else]{$a}[end]
    {$Primary} / {$Secondary} 
    
    Table: Origin
    Android
    Cockroach
    Doppleganger
    Electrokinetic
    

    which outputs:
    Android / Electrokinetic 
    Cockroach / Engineered Human 
    Doppleganger / Cockroach 
    Cockroach / Android 
    Cockroach / Doppleganger
    
  • Thanks, that explains a lot!

Leave a Comment