O'Reilly logo

A Beginner’s Guide to Writing Minecraft Plugins in JavaScript by Walter Higgins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Multisided Die

In this chapter, you’ll build on the code written in the previous chapter to let you roll a die of any number of sides. Sometimes you want a random number that doesn’t fit in the range 1 to 6. Ideally, you’d like your virtual dice module to return a random number for any range you give it. You’re going to take your six-sided die from the previous chapter and enhance it so it can change shape to any number of sides like the multisided die used in some tabletop and role-playing games (see FIGURE 7.1).

Image

FIGURE 7.1 Multisided dice

Flexible Functions

If you wanted to expand on what you’ve already done to support dice of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required