GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • Tutorials
  • Rainbow Beacon

This view

  • Original page
  • New address

GeezerVison is showing minecraft.makecode.com — Rainbow Beacon

Skip to main content
About FAQ Projects GitHub
Examples
Super Powers
Mega Jump Flower trail Super Digger Yellow brick road Game Over
Agent
Agent Dig Agent Tower Agent Checkers Agent Wanderer Agent Pyramid Hilbert Fractals
Mobs
Chicken Rain Zombie Pig Cats vs Dogs Rabbit Invasion Bouncing Pigs Bat Cave
Terraforming
1000 TNT Wipe Out Lava Tower Earthquake Pitfall Grid world Lorenz Attractor
Mini Games
Spleef Leap of Faith Gold Stairs TNT Spleef Gladiator Ice Age
Builder
Builder Wall 3D Axis Compass Build a House TNT Cannon
Courses
CS Intro
About
Lessons Blocks Minecraft Authors
Events
Overview Unplugged 1 Unplugged 2 Activity 1 Activity 2 Activity 3 Activity 4 Project
Coordinates
Overview Unplugged 1 Unplugged 2 Activity 1 Activity 2 Activity 3 Project
Variables
Overview Unplugged Activity 1 Activity 2 Activity 3 Activity 4 Project
Iteration
Overview Unplugged 1 Unplugged 2 Activity 1 Activity 2 Activity 3 Activity 4 Project
Conditionals
Overview Unplugged Activity 1 Activity 2 Activity 3 Activity 4 Project
Functions
Overview Unplugged Activity 1 Activity 2 Activity 3 Project
Arrays
Overview Unplugged 1 Unplugged 2 Activity 1 Activity 2 Activity 3 Project
Artificial Intelligence
Overview Unplugged Activity 1 Activity 2 Activity 3 Project
Final Project
Review Guide Project
Reference
Player Blocks Mobs Agent Builder Gameplay Positions Shapes
Blocks
On Start
Loops
repeat for while for of
Logic
if Boolean
Variables
assign change var var
Math JavaScript blocks Custom blocks
Python
Calling Sequencing Variables Operators Statements Functions Classes
JavaScript
Calling Sequencing Variables Operators Statements Functions Types Classes Interfaces Generics
Types
Number String Boolean Array Function
Get setup Blocks Gallery
Miscellaneous
About Support Translate Sharing projects Offline support Save Reset Beta version Home page content
Developers
Command Line Interface Visual Studio Code support Blocks Embed
Tutorials
Chicken rain Agent Moves Agent Build Agent Wall Mega Jump Walk On Water Flower Trail Positions Super Digger Billboard Compass Rose Fast Forward Spleef Leap of faith Gold Stairs Lava Tower Rainbow Beacon Colorful Rainbow Sand Storm Aquarium Leaping Salmon
Python Tutorials
Chicken rain Agent Moves Agent Build Mega Jump Flower Trail Super Digger Billboard Compass Rose Fast Forward Spleef Leap of faith Gold Stairs Lava Tower Sand Storm Aquarium Leaping Salmon
Using Extensions
Castle Builder Roller Coaster Pixel Art Builder
Lessons
Area AI - Part 1 AI - Part 2 Ratio Volcanoes - Part 1 Volcanoes - Part 2 Storyline Story ending Cubic units Gold mine

Rainbow Beacon

Create colorful World markers!

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!

Rainbow Beacon

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.

Click on the ||variables:list|| drop-down and select Rename variable... Type in rainbow as the name of our array.

let rainbow = [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 rainbow 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 rainbow = [RED_CONCRETE, ORANGE_CONCRETE]

Add more blocks

In the ||arrays:set rainbow 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 rainbow = [
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 to player's position

From the ||player:Player|| category, drag the ||player:player world position|| block into the ||variables:set location|| block replacing the 0. This will set the location to the player's position in the world.

player.onChat("beacon", function () {
    location = player.position()
})
let location: Position = null

Loop through array

Now let's loop through our rainbow array of blocks. Open the ||loops:Loops|| Toolbox drawer, and drag a ||loops:for element value of list|| block out into the ||player:on chat command|| block. In this block, click on the ||variables:list|| drop-down and select ||variables:rainbow||.

player.onChat("beacon", function () {
    location = player.position()
    for (let value of rainbow) {
    	
    }
})
let location: Position = null
let rainbow: number[] = []

Place a block from rainbow array

From the ||blocks:Blocks|| Toolbox drawer, drag a ||blocks:place block at|| block into the ||loops:for element value of rainbow|| block.

Then drag the ||variables:value|| block out of the ||loops:for element value of rainbow|| block and into the ||blocks:place block at|| block replacing the grass block. This will place a block from our rainbow array.

player.onChat("beacon", function () {
    location = player.position()
    for (let value of rainbow) {
        blocks.place(value, pos(0, 0, 0))
    }
})
let location: Position = null
let rainbow: number[] = []

Place the block at the location

We need to make sure we're building the beacon at the correct spot. Open the ||variables:Variables|| Toolbox drawer, drag a ||variables:location|| block out and drop into the ||blocks:place value at|| block replacing the relative player coordinate block.

player.onChat("beacon", function () {
    location = player.position()
    for (let value of rainbow) {
        blocks.place(value, location)
    }
})
let location: Position = null
let rainbow: number[] = []

Reset the location coordinate

After each block we place, we want to place the subsequent block on top of that one. So we need update the location coordinate.

From the ||variables:Variables|| category, drag another ||variables:set|| variable block out and drop inside our ||loops:for element value of rainbow|| block just after the ||blocks:place value at location|| block.

Click on the variable drop-down and select the ||variables:location|| variable.

From the ||positions:Positions|| category, drag an ||positions:add positions|| block out and drop into the ||variables:set location|| block replacing the 0.

player.onChat("beacon", function () {
    location = player.position()
    for (let value of rainbow) {
        blocks.place(value, location)
        location = positions.add(
        pos(0, 0, 0),
        pos(0, 0, 0)
        )
    }
})
let location: Position = null
let rainbow: number[] = []

Add positions

Increment the current location coordinate by 1 block up. To do that, open the ||variables:Variables|| Toolbox drawer, drag a ||variables:location|| block out and drop into the first field of the ||positions:add positions|| block. Then in the second position field, type a 1 in the middle (y) coordinate - this represents 1 block up.

player.onChat("beacon", function () {
    location = player.position()
    for (let value of rainbow) {
        blocks.place(value, location)
        location = positions.add(
        location,
        pos(0, 1, 0)
        )
    }
})
let location: Position = null
let rainbow: number[] = []

Test your code

Let's try out our code and see what happens. Press the green Play button to run our code in the game. Move your player to a place on the ground, press T to open the chat window and type in beacon. What happens?

Build it higher!

Pretty cool! 🟥🟧🟨🟩🟦🟪 We built a tower of rainbow blocks at our player's position!

But it's a bit short. For a beacon to be effective, it needs to be very tall so you can see it from a long ways off. To build it higher, let's use a loop.

Open the ||loops:Loops|| Toolbox drawer, and drag a ||loops:repeat 4 times|| block out and place it around the ||loops:for element value of rainbow|| block.

In the ||loops:repeat 4 times|| block, change the 4 to a 10 to make it really high!

player.onChat("beacon", function () {
    location = player.position()
    for (let index = 0; index < 10; index++) {
        for (let value of rainbow) {
            blocks.place(value, location)
            location = positions.add(
            location,
            pos(0, 1, 0)
            )
        }
    }
})
let location: Position = null
let rainbow: number[] = []

Create your beacon

Press the green Play button to run your code in the game. Press T to open the chat window and type in beacon. You should see a very tall colorful beacon stretching up to the sky!🌈 Great job! 🌈

player.onChat("beacon", function () {
    location = player.position()
    for (let index = 0; index < 10; index++) {
        for (let value of rainbow) {
            blocks.place(value, location)
            location = positions.add(
            location,
            pos(0, 1, 0)
            )
        }
    }
})
let location: Position = null
let rainbow: number[] = []
rainbow = [
RED_CONCRETE,
ORANGE_CONCRETE,
YELLOW_CONCRETE,
LIME_CONCRETE,
LIGHT_BLUE_CONCRETE,
PURPLE_CONCRETE
]

Edit this page on GitHub
Edit template of this page on GitHub
Edit template of this page on GitHub

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.