Deck picks on Lookup with variable repetitions

This code runs an example of the issue I am having in a larger generator. Some of this code may not be 100% relevant but I provided it as it is a skeleton of my greater generator's format. If run, sometimes you will see duplicates in what should be a deck pick (thus distinct). Is this due to using a variable as the number of repetitions? Or possibly due to the fact that it is rolling on a deck that is a Lookup table? I can't figure out why it isn't working and would appreciate any guidance.
*note- I weighted the numbers as to create more duplicates/deck picks in the calculate table.
*note- ipt file attached

Thanks!

- moosebiter
Set: var = 0 // declare a global variable for the number of times to make the deck pick

// makes 15 rolls on the table that makes the deck picks
Table: main
[@15 deck_pick_call]

// this table calculates the number of adjectives, then makes variable number deck picks
Table: deck_pick_call
Set: var = 0 // intended to reset the variable, may be redundant
shuffle: subtable // seems to be the correct usage but I cant tell since the deck picks aren't working
Type: Lookup
Roll: 1d100
1-50: [@calculate][when] {$var} > 0 [do][!{$var} deck >> sort >> implode]; [end]Antelope\n{var == 0}
51-100: [@calculate][when] {$var} > 0 [do][!{$var} deck >> sort >> implode]; [end]Rabbit\n{var == 0}

// this is the deck to draw adjectives from from
Table: deck
Type: Lookup
Roll: 1d100
1-30: fast
31-36: tired
37-50: slow
51: hungry
52-60: flying
61-63: eating
64-70: sneaky
71-72: slippery
73-80: round
81: dead
82-86: lively
87-99: short
100: tall

// adds 2 to var until 1-60 is rolled
Table: calculate
Type: Lookup
Roll: 1d100
1-60: \z
61-100: {var == {var} + 2}[@calculate] // add 2 and roll again

Comments

  • Hi.
    As far as I investigated, it's a problem, or rather the result of using lookup table.
    I'll skip long explanation why it is so, but just use simple weighted table like:
    Table: deck
    30: fast
    8: tired
    14: slow
    1: hungry
    9: flying
    3: eating
    17: sneaky
    2: slippery
    8: round
    1: dead
    5: lively
    13: short
    1: tall
    
    Using variable number of picks have nothing to do. Following example works like a charm for me:
    Table: example
    set: v={1d6}
    shuffle: subtable
    [!{v} subtable >> implode]
    
    Table: subtable
    a
    b
    c
    d
    e
    f
    g
    h
    
    BTW You have shuffle: subtable but table named deck.

    Regards
  • That did it, thanks!

    I guess I'll write a small program outside of IP to convert all of my decks to weighted tables instead of Lookups to save myself some time.

    Thanks for pointing out the bad shuffle reference too. I wrote this smaller generator quickly and didn't catch that when I renamed the deck to make it clearer :)

    - moosebiter
  • I'm glad to hear it worked.
    One more thing to be careful about:
    "Set: var = 0" as written, with spaces, sets variable "var" with value "<space>0" that is auto-magically converted to numeric value zero "0", but "Set: var = a" gives us "<space>a" and leading space is not trimmed.
    Set: var = 4
    123{var}567
    Result: 1234567 // no space because successful to-numeric conversion
    
    but
    Set: var = d
    abc{var}efg
    Result: abc defg // returns unwanted space as everything pass "=" is assigned to var, and it's kept as text variable
    
    I like space formatted code as well, but for "Set", it's better to keep it space-less like "Set: var=value".

    Inspiration Pad have it's quirks, but it's great, and really useful tool.
    Good luck with your tables.

Leave a Comment