D20 Dice Rolls Help

I would like to know how sustainable the Frankenstein code I made for rolling D20s for skill checks is. Mainly, it works, I think, but is there a way to tell if it is working as intended?

I am not getting errors anymore and it seems to alternate between fail and success but I have no idea if it’s actually doing what I want it to?

I threw it together using some pastebin guides by Michael Maxwell as well as a guide on *rand rolls.

Example:

*create strength 10
*create d20 0
*create strengthmodifier 0
*create rollresult 0

*page_break
Blah blah
*fake_choice
   #blah
      *set strength+10

Blah
*fake_choice
  #blah
    *rand d20 1 20
    *set strengthmodifier (strength/10)
    *set rollresult (d20 + strengthmodifier)
    *page_break
    *if (rollresult >= 13)
         Yay

    *if (rollresult < 13)
         Boo

*page_break

Blah blah blah
*finish

With this system how do I avoids the stats page rerolling thing? The page_break doesn’t seem to be enough but what should I do? I’ve tried everything but nothing works.

I also tried

*create strength 10
*create d20 0
*create strengthmodifier 0
*create rollresult 0
*create rollsuccess “false”
*create rollfail “false”


*page_break
Blah blah
*fake_choice
   #blah
      *set strength+10

Blah
*fake_choice
  #blah
   *gosub skillchecks
   *if (rollresult >= 10)
        *set rollsuccess “true”
        *goto next1
   *if (rollresult < 10)
        *set rollfail “true
        *goto next 1




*label skillchecks
*rand d20 1 20
*set strengthmodifier (strength/10)
*set rollresult (d20 + strengthmodifier)
*return

*label next1
*if (rollsuccess = true)
     Yay
     *page_break

*if (rollfail = true)
     Boo
     *page_break

Blah
*finish

And I’ve tried atleast five to six iterations of the second one with no success. I’d appreciate help figuring out how to stop the rolling loop and if my code even is rolling correctly.

4 Likes
   *if (rollresult < 10)
        *set rollfail “true
        *goto next 1

There is a space between “next” and “1”

The *page_break after *rand but before the results are shown works well enough. Because you can reroll all you want going in and out of Show_Stats, but you won’t know your role until you click to the next page, and by then, you can no longer change your roll.

I’ve run into issues where this doesn’t work every single time, but it after putting the *page_break in a different scene, like putting it into a different .txt file for subroutines and scripts, it works 100% of the time.

Your second example works best. But you’ll have to move the *page_break up the chain at the end of skillchecks

Like this.

*label skillchecks
*rand d20 1 20
*set strengthmodifier (strength/10)
*set rollresult (d20 + strengthmodifier)
*page_break <<-------- Added here
*return

*label next1
*if (rollsuccess = true)
     Yay
     *page_break

*if (rollfail = true)
     Boo
     *page_break
10 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.