Lightning Strike Spell

Planning
Step 1
In this lesson you will use what you've learned to add a spell that causes a lightning strike at the target location

It is recommended that you complete The Wand, the Midas Touch, and the setSpell() Function lessons before attempting this challenge unless you have prior experience with custom items, the PlayerInteract event, and exporting functions.

Temp1477686956
Challenge
Step 2
CHALLENGE: Add a new item based on the Magic Wand that has the spell set to "Lightning Strike"

NOTE: You do not need a crafting recipe for this wand since we will be using the setSpell() function to give it to the player.

Temp1477687246
Challenge
Step 3
CHALLENGE: Add "Lightning Strike" to your setSpell() function

You should be able to use the command /js setSpell("Lightning Strike") to place the wand you made in the previous step in your hand.

Temp1477687358
Challenge
Step 4
CHALLENGE: Add code to your onPlayerInteract function that allows you to cast the lightning spell
  1. Check the action the player performed
  2. Check the item in the player's hand
  3. Use world.strikeLightning(location); to cause a lightning strike at location
Temp1477687493
Check Your Work
Step 5
Make sure everything is working properly

Once you have successfully completed this challenge try to think of another spell you would like to add that would use the PlayerInteract event in a similar way.

Lightning Strike Spell Info

Account

MVCode Clubs

Created By

Mvcc logo new aaron

Course:

Wand World

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