{ if( 1d20 >= 15, 'hit', 'miss')} help, where am i messing this up?

Hello Ed,

Sorry to pester you here.
I went through help files and forums but could not find an answer here.
I am making AD&D treasure tables and when I get to the magic-item chance i use this code but I keep getting an error of

(Invalid expression: if( 1d100 <= 30, '** it pulls the results no matter what the d100 roll is **', '0'))

THE CODE:

TABLE: TTA10MAGIC
{if( 1d100 <= 30, '\n [@{1d3} MagicTRMAIN]', '0')}
; { if( 1d20 >= 15, 'hit', 'miss')}
#
TABLE: MagicTRMAIN
ROLL: 1d100
01-20: \n [@PotionsMST] onset time is {1d4+1} segments, duration is {1d4+4} turns
21-35: \n [@ScrollsMST]
36-40: \n [@RingsMST]
41-45: \n [@RSWMST]
46-48: \n [@MME1MST]
49-51: \n [@MME2MST]
52-54: \n [@MME3MST]
55-57: \n [@MME4MST]
58-60: \n [@MME5MST]
61-75: \n [@ASMST]
76-86: \n [@SwordSizeRoll]sword [@SwordsMST][@ASMSTUnusualSwords]
87-100: \n [@MWMST]
;this goes to the subtables for magic items that all work as a stand alone magic item table.

For the life of me I've been beating my head on this for days now and I can't see how i'm off from the help file code for the function

{if( 1d100 <= 30, +results, -results)}

thank you for your help

Comments

  • This seems to work

    table: test
    {if( 1d100 <= 30, '\n [@{1d3} MagicTRMAIN]', '0')}
    
    
    table: MagicTRMAIN
    hello
    

    It generates a bunch of 0's and an occasional 'hello'

  • edited August 2016

    I installed this code and ran. On run #3 i got this error.

    Magic Items (Invalid expression: if( 1d100 <= 30, 'hello', '0'))

    It seems to work ok to give me a "0" when the d100 is above 30 but errors when it is below 31.

  • UPDATE: I have noticed that the out put errors whenever one of the results has an " ' " in it like Bob's Spell. If none of the results has an ( ' ) in it then there is no error.
    Can anyone think of how to use an apostrophe ( ' ) in my chart results without IPP reading it as a programing code? or should I switch it to ( ` ) instead?

  • it works with the ` instead of the ' minor but fictional!!!

  • You can probably put this instead of an apostrophe:

    & #39;

    Except leave out the space between the & and the # (I can't type it that way or it will display as an apostrophe!).

  • I tried that jdale and it printed the apostrophie BUT that still crashed the program. So I just am in the process of changing all the ' to ` and they are working

  • You should be able to use double quotes instead of single quotes around the table result, like:

    {if( 1d100 <= 30, "\n [@{1d3} MagicTRMAIN]", '0')}

    That may cause a problem with items that have double quotes in them. So it really depends on what your tables look like.

Leave a Comment