TeachCraft Lesson 6

Bow/Arrow as a Magic Code-Wand

Similar to lesson 5, we're going to poll for events! However this time, we're going to use a bow/arrow instead of a sword! Each event we get will be the block that an arrow we shot landed in - this will let us target code-spells at whatever location we shoot!

In this specific example, it's setup so when you shoot a block with an arrow, your code is executed.

Whereas in lesson 5's example with a sword, we polled the function
mc.player.pollBlockHits(), while in this example we will poll the function
mc.player.pollProjectileHits().
In our for loop, each loop's blockhit variable contains information on the block you hit, and we can access its position via
blockhit.pos

In the script on the right, everytime we shoot a block with a arrow, the code executes that turns that block into gold. Try it!