Dungeon Game 3: Starting and Finishing Touches

Step 1
Place a stone pressure plate

We want to start our dungeon with a pressure plate instead of calling a function. This way we won't need to OP players who are trying our dungeon.

Place a stone pressure plate somewhere in the main room to start the dungeon. Here it is on the edge of the well, because who could resist the temptation to try to see how deep it is?

Temp1534610119
Step 2

Save the plate's location as a variable.

Temp1534610736
Challenge
Step 3
What type of action is stepping on a pressure plate?

There are several different types of player interact actions, and you can find the complete list of them here on the Bukkit API. Use the code below to figure out what type of action stepping on a pressure plate is considered to be.

Temp1534741962
Step 4
Test the action type you discovered

Use an if statement to check only for the action type of a pressure plate step, and use a broadcast message to make sure that it is working.

Save, deploy, and reload on your server and step on a pressure plate. Try left and right clicking blocks and the air to make sure that only the pressure plate gives you the message.

Temp1534741855
Step 5
Convert the startDungeon() function

Before, we made startDungeon() an export function, so that we could call it in the command line of Minecraft. Because it was an export function, we could use the keyword self to refer to whoever typed it in the console.

We need to change this function so that it takes an input (also called a parameter), so it knows what player to make playerOne.

Temp1534742963
Step 6
Call the startDungeon() function when the pressure plate is stepped on.
Temp1534791052
Step 7
Add a title and adventure mode

Add these lines to show the title of this temple and place the player in Adventure Mode, so that they cannot break blocks.

Temp1534743939
Information
Step 8
Equipping Players

Let's take a look at some code from the Capture the Flag lesson.

This function takes two inputs, player and color.

The color here needs to be one of the existing Minecraft colors. Here are some examples:

color.purple
color.orange
Temp1534743700
Challenge
Step 9
Equip your player

Create a function called dressPlayer that takes player as an input.

Using the information from the previous step, give the player a complete set of leather armor.

Temp1534745484
Step 10
Give the player a sword
Temp1534746296

Add the following code to clear out any items the player came in with, and give them an iron sword. After we empty the inventory, we call our equipPlayer() function to give them the leather armor.

Challenge
Step 11
Make a function to check if all the rooms are finished

Make a function called dungeonRoomsFinished. It should:

  • Use a for loop to go through all the rooms in the dungeonRooms array.
  • if any of the rooms is not finished, it should return false
  • once the whole loop finishes, it should return true since return would have ended it early.
Check Your Work
Step 12
Test out your function

Use your new function in the checkPlayerPosition function to get a message when all the rooms are complete.

Temp1534785635
Challenge
Step 13
Make a roomsFinished variable

Make a new Boolean (true/false) variable called roomsFinished that starts out false.

Too keep the code from going over and over again like the broadcast message, we need to have this code run only if the rooms aren't already finished, and set it to true so that the code only happens once.

Step 14
Get the coordinates for the top of the fountain

When all the rooms are finished, we are going to place a water block at the top of the well to start the fountain. Use the same method we used for the rooms to get the coordinates for the location, and save it to a global variable called fountainLoc

Temp1534787203
Challenge
Step 15
Start the fountain!

Inside of the checkPlayerPosition() function:
- teleport the player to the dungeon entrance again
- create a new drone at fountainLoc and have it place a water block there.

Challenge
Step 16
Make the drone code for the Boss Fight chamber

Make a new export function called buildBossChamber() to create a chamber at the bottom of the well.

You will need to use:

  • box()
  • box0()
  • cylinder()
  • cylinder0()
Temp1536869953
Dungeon Game 3: Starting and Finishing Touches Info

Account

MVCode Clubs

Created By

Mandala2 slinkous

Course:

Temple Dungeon

Access Level

premium

For Teachers and Schools

Teach coding to your students with MVCode Teach

MVCode offers an integrated product designed to teach coding to students.

Learn more about MVCode Teach