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 6. Rolling Dice

Traditional board games such as Ludo, Monopoly, and Snake & Ladders all have an element of chance. Success is sometimes based solely on luck and the roll of the dice. In this chapter, you’ll create a JavaScript module that mimics a six-sided die (the standard die that comes with most board games). You’ll reuse this module in later chapters to give random greetings to players who join the game.

In this chapter, I’ll walk you through creating your first reusable JavaScript module.

Randomness

When you throw a six-sided die, there’s no way of knowing what the throw will be; it can be any number between 1 and 6, but it’s impossible to know ahead of time. The number thrown is said to be random. Computers can also provide random ...

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