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 10. Animal Sounds

In this chapter, you’ll create a simple program to ask players a question and play back sounds based on the answer given. You’ll learn about JavaScript’s switch statement and ScriptCraft’s sounds module. The new program will ask players what their favorite animal is and play back that animal’s sound.

The switch Statement

In Chapter 9 you learned how to get input from players and how to test the input using JavaScript’s if statement. JavaScript provides an additional statement for testing values: the switch statement. The switch statement is useful when you want to make decisions by testing a single value. The switch statement is best explained by example. Create a new file called animalSounds.js in the scriptcraft/plugins/ ...

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