Variables in Minecraft

Step 1
Variables

Variables are pieces of information we tell the computer to store

They can be:
  • set - assigned a value
  • read - use the value inside them

Step 2
Create a message variable

A variable is created by using the var keyword and giving it a name

Step 3
Assign a value to your variable

We assign a value to a variable by using an = between the variable and value;

The variable being assigned a value goes to the left

The value goes to the right

Step 4
Add a function to set our message to a new value
Step 5
Set message to the value passed to the function
Check Your Work
Step 6
Set a new message!
Step 7
Add a function that fires when an entity (creature) is damaged
Step 8
Create a variable to store the entity (creature) associated with the event

creature is a variable that stores the entity which received damage

Step 9
Check if the damaged creature is a player
Step 10
Output our message to the damaged player
Check Your Work
Step 11
Fight a spider
Planning
Step 12
We will now make a series of functions to create and control explosions
Challenge
Step 13
Choose a power level for the explosion we will be creating

This number must be smaller than 50

Challenge
Step 14
Create a function to set the value of loc to your current location
Step 15
Exports
Challenge
Step 16
Create a function to set a new value for power
Challenge
Step 17
Create a function to set world to a new value
Step 18
Create explosions!
Check Your Work
Step 19
Set a power
Check Your Work
Step 20
Set a location
Check Your Work
Step 21
Set a world
Check Your Work
Step 22
Cause an explosion!
Information
Step 23
That's it!

You now know about Variables

Variables in Minecraft Info

Account

MVCode Clubs

Created By

jake wheaton

Course:

Fundamentals in Minecraft

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