Highlight a Location
To prepare for next lesson, Events, we'll learn to call another function in CodeCraft. This function can highlight the location of your mouse on the screen so you can perform actions like placing blocks and other structures wherever you click.
Type in this function to your console:
game.highlight("air")
Here, the string "air"
means "empty block". This function highlights an empty spot adjacent to a solid surface where the mouse points to.
Click 'run' and enter the CodeCraft world. Move the mouse around, and you'll notice that when the mouse is next to a solid block, the adjacent "air"
block will be outlined.
This function helps you see the mouse location where you are going to perform some magic, like building a wall, a fancy flower or even a giant castle on the click of a mouse.
Yes, in CodeCraft you have the power to build anything! To get a glimpse of this magic, turn to the next page.