Lucy in the Sky with Diamonds was a popular 1960s Beatles tune. Before you ask, yes, I am old enough to have been there. The screenshot below is from a little MakeCode chat command using a print block with text “Lucy” and diamonds to do the printing.
There are a few things we can learn from this code about blocks, positions and directions.
Which blocks (e.g., diamonds, grass) can be used to write in the sky?. Change diamonds to sunflowers. What happens? Lava? Water?
The position means 50 blocks east, 5 blocks high and 0 blocks south relative to the player; that is, from where the player is standing.
The phrase gives the direction to print. I think of the player as facing east, so printing along South means printing left to right. What happens if the along phrase is changed to each of the following:
Keeping Score in the Sky
In Grandma’s Chickens, I used a similar function to keep score of how many chickens the player zapped.
The “run” chat command is for testing the function printScore
The first say block signals that the program is actually running. The last say block indicates when it is complete. Why are these needed? Sometimes when “run” is typed into the command line, the program does not start. This may be because , the start button, was not pressed. Other times are more mysterious, but I have found that when repeated attempts to start a program fail, restarting Minecraft and MakeCode solves the problem once again proving the old adage “When in doubt, reboot.”
In the chat command “run,” the original player world position is saved in the variable “center.” This allows the player to move while the program is running. This is desirable because the view of the what’s happening in Minecraft is often better if the player is allowed to move to a different vantage point rather than being required to stay in one place because all positions are relative to the player and change as the player moves.
The repeat loop in “run” calls the printScore function 5 times to test randomly selected values for score..
The function printScore performs as its name indicates. It first converts the number variable score to text, which is required by the print block. The say block outputs the score to the log window.
In the print block, by joining txtScore with trailing spaces, the digits of any longer number that had been previously printed to the same location are erased.
Pay particular attention to the manner in which position is specified by the at phrase. The position is not specified as relative to the current player world positon but, rather, as relative to the original player world position, which was saved in the variable “center.” Notice that is a world position, not relative. The print position is center X plus 40, center Y plus 5, center Z minus 5. The value of these coordinates were determined by trying various numbers to find a visually appealing positon.
Demo of App and Code
Get the Code
The code for Print Score and Lucy is shared at https://makecode.com/_HpX7bY2ehM3H . It can be downloaded and run in MakeCode for Minecraft.