Help with code

I am making a percentile dice roller, I have it working... somewhat. I tried to set the conditional for the ones to be "0" when the tens are "10".
The code is here:
Table: Percentile Dice
[@result=Tens&;#93;[@result2=Ones&;#93;%
[when] Tens=10 [do] Ones=0 [end]
Table: Tens
Roll: 1d20
1-2:1
3-4:2
5-6:3
7-8:4
9-10:5
11-12:6
13-14:7
15-16:8
17-18:9
19-20:10

Table: Ones
Roll: 1d20
1-2:1
3-4:2
5-6:3
7-8:4
9-10:5
11-12:6
13-14:7
15-16:8
17-18:9
19-20:0

The problem is, some results come back blank. So I tried adding this line:
[when] Tens=10 [do] Ones=0 [else] [@result=Tens&;#93;[@result2=Ones&;#93;% [end]
Now I am back to getting results of 100-109%. Can someone take off my stupid stamp? :? I am just not seeing the problem well enough to fix it.
:roll: By the way, I set the tables up the way they are because just rolling 1d10 never resulted in 10's.

Comments

  • I would do something like:

    Table: percentile
    [@d&;#93;[@d&;#93;
    
    Table: d
    Type: Lookup
    Roll: 1d10
    1:1
    2:2
    3:3
    4:4
    5:5
    6:6
    7:7
    8:8
    9:9
    10:0
    
  • I'm wondering what's wrong with just doing it this way?
    Table: Percentile Dice
    {1d100}%
    

    Works just fine.
  • Code is tricky. using 1d100 type randomizer will result in common numbers in the middle because the code is randomiing linearly. Ever go to a carnival and play that game where you push the car and it bounces back and forth until it stops almost always in the middle. The larger the range the more severe the common numbers are or middle numbers. using a d10 is only a tenth of the range and therefore much more accurate.
  • Then why not just:
    Define: percent={1d10-1}{1d10-1}
    [when] percent==00 [do] percent==100

    or something like that

    Realized this a bit ago, but haven't had time to post it:
    percent ={!{1d10-1}*10+{1d10-1}+1}

    What I've done is shift the range from 0-99 to 1-100

    Of course, a good question is, How does IP handle large randoms? If they already break it down in the code, then this is pointless.

Leave a Comment