New Novice user, "if" help

This is a section of a larger random monster generator I am working on for Numenera. This part takes the level variable established earlier in generation and compares it with a 1d10 roll. If the roll is less than the level, the generator proceeds to make picks from the powers list equal to the difference. I've almost gotten it working a couple times, but I think there must be something fundamental in the syntax that I'm not understanding. Thanks in advance for any help or pointers anyone can give.
; test.ipt
; created 7/22/2014 1:00:12 PM
 set: level={1d10}
 set: power={1d10}
 
Table: powerchance
{if ({power}<={level}, [!{({level}-{power})} powers >> implode], 'None')}

table: powers
drains might
drains speed 
drains intelect
absorbs damage
acid blood

Comments

  • Hi turtlejet, welcome to the forums!

    Personally, I've always found the "if" syntax to be a little flaky. Possibly it's just a lack of understanding on my part. Regardless, InspirationPad provides an alternate syntax, "when". Here's how I was able to get your code running using "when".
    ; test.ipt
    ; created 7/22/2014 1:00:12 PM
    set: level={1d10}
    set: power={1d10}
    
    Table: powerchance
    {power} {level}  [when]{power}<{{level}+1}[do][!{({level}-{power})} powers >> implode][else]None[end]
    
    table: powers
    drains might
    drains speed 
    drains intelect
    absorbs damage
    acid blood
    

    Some notes: I added the "{power} {level}" bit at the beginning of the line just to see that the code was doing what I wanted. You can delete that part painlessly. Also, for whatever reason the "<=" symbol didn't work right, so instead I went with "<" and just added 1 to the level. Kludgy, but it got the job done.
  • That did the trick! Thank you!

    It's odd that "when" works in the same situation that "if" doesn't. Is there anything "if" does particularly well?

    Also, I have nothing against kludge as long as it works!

    Thanks again.

Leave a Comment