Rainbow Beacon
Create colorful World markers! @showdialog
Beacons are useful markers in a Minecraft world to help you find your house or spawn point again. Let’s make a rainbow colored beacon with code!
Create an array of blocks
The first thing we’ll do is create an array of colored blocks. An array is a list of things.
Click on the Advanced section of the Toolbox to expand. From the ||arrays:Arrays||
category, drag a ||arrays:set list to array of (0) (1)||
block out to the workspace and drop into the ||loops:on start||
block.
let list = [0, 1]
Populate array
From the ||blocks:Blocks||
Toolbox drawer, drag out 2 of the ||blocks:grass block||
blocks and drop them into the ||arrays:set list to array of||
block replacing the 0 and 1.
Then click on the ||blocks:grass block||
drop-down menus to select different colored blocks (like red and orange concrete).
let list = [RED_CONCRETE, ORANGE_CONCRETE]
Add more blocks
In the ||arrays:set list to array of||
block, click on the plus (+) icon several times to expand the array to include more blocks. Select different colored blocks to make up a rainbow!
let list = [
RED_CONCRETE,
ORANGE_CONCRETE,
YELLOW_CONCRETE,
LIME_CONCRETE,
LIGHT_BLUE_CONCRETE,
PURPLE_CONCRETE
]
Change On Chat Command
Change the ||player:on chat command||
block on the workspace from “run” to “beacon”.
player.onChat("beacon", function () {
})
Set location variable
Now let’s set a location to start building our beacon.
Open the ||variables:Variables||
Toolbox drawer, and click to Make a Variable. Name this variable “location”. Now from the ||variables:Variables||
category, drag a ||variables:set location to||
block out and drop into the ||player:on chat command||
block.
player.onChat("beacon", function () {
location = 0
})
let location = 0
Set location in front of player
From the ||positions:Positions||
category, drag the ||positions:right(0) above(0) in front(0)||
block into the ||variables:set location||
block replacing the 0. Then type 1 in the ||positions:in front||
field replacing the 0.
player.onChat("beacon", function () {
location = posCamera(0, 0, 1)
})
let location: Position = null