Site icon We Code MakeCode

Code Part 2 — on-Chat Commands for Riding the Rail in MakeCode for Minecraft

The Code that Processes on-chat Commands that Launch Riding the Rail

The code in the not-grayed-out area to the upper left in the screenshot below launches Riding the Rail. These chat commands define the MOBs to be spawned and the order in which they will be spawned.

Goals for Riding the Rail included the following user-interface requirements:

The structure of the on-chat commands were the first step in accomplishing these goals. For new players there is an on-chat command for each MOB type; for example, when the program is launched with on-chat command “vindicator,” only vindicators will be available for riding the rail. Every time a MOB is placed on the rail, it will be a vindicator. Similarly, when started with “llama,” every MOB spawned will be a llama. For advanced players, the on-chat command “selected” will cause a player-modifiable function to be used to chose the MOBs thus enabling the ultimate in flexibility.

The on-chat commands that launch the program fall into the following two groups:

Commands for Only One MOB Type

The simplest way to launch Riding the Rail is to type the name of a MOB in the chat window. The MOB name launches one of the code snippets in the picture below.

Each MOB name does the same thing except for setting the variable MOB_to_add to the chosen animal or monster. For example, the code below set MOB_to_add to the monster vex and calls the function run_one_MOB_type.

The function run_one_MOB_type does the following:

Commands for More than One MOB type

The on-chat commands in the picture bellow can add more than one MOB type to the list of MOBs available to be spawned. These eight commands, are easier to remember interfaces to the “run” command (discussed next). These commands specify which MOBs to add to the spawn list and the order in which the are removed from the list, which can be either as ordered in the list or randomly selected from the list.

The above eight commands, call the run command with the appropriate two arguments:

Code Requires a Flat World

This code assumes a flat world such as that described in MakeCode for Minecraft Sandbox World: Make It Flat and Simple.

Get the Code

Riding the Rail code is shared on Code Connection at this URL

https://makecode.com/_bPdMMvgg5Mjw

To get and use the code, follow these steps.

Click the Import button , which is upper right in the Code Connection window just below the banner. This will open the window shown below.

Click the Import URL button , which is on the right, to open the window shown below.

Paste the URL supplied for the program you want to use in the space under the text “Copy the URL …”

Click the Go ahead! button .

The next window you will see will be the MakeCode window with the code downloaded from the URL. At this point, you can treat it like any other code, e.g., run it, save it locally, modify it, publish your changes or whatever else your heat desires.

We have tested several other methods of downloading the code using the URL, for example, pasting the URL in a browser. No joy. For more detailed instruction see our post How to Use Shared MakeCode on Microsoft Code Connection for Minecraft.

Exit mobile version