Variables in Minecraft

Step 1
Variables
Temp1547068463

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
Temp1547068641

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

Step 3
Assign a value to your variable
Temp1547068898

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
Temp1547069100
Step 5
Set message to the value passed to the function
Temp1547158991
Check Your Work
Step 6
Set a new message!
Temp1547161621
Step 7
Add a function that fires when an entity (creature) is damaged
Temp1547159763
Step 8
Create a variable to store the entity (creature) associated with the event
Temp1547160469

creature is a variable that stores the entity which received damage

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

This number must be smaller than 50

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

You now know about Variables

Temp1547505919
Variables in Minecraft Info

Account

MVCode Clubs

Created By

Missing tiny 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