Command block

Command Blocks are a function in Junon.io. As opposed to /help commands, which are manually written in the chat, Command Block commands allow for automatic changes, events, and gameplay. This allows players to play in a server without the assistance of an owner/admin.

Remember values like "survival tool" or "copper asteroid" must be written like "survival\_tool" or "CopperAsteroid". Undercase letters and underscores are used in Commands, but in everything else they have capitalization and no spaces.

## Triggers

Triggers are the events that have to happen for a coded event to happen. For example, if a player writes code so that potatoes heal 100 health, the trigger would be ItemConsumed, because the potato would have to be eaten for the player to heal.

For a full list of triggers, go to the Triggers page.

### How to Use Triggers

Triggers are used as the cause to the effect. If you want something to happen (for example: the Green Energy Sword to inflict the poison effect when hitting an entity) you have to identify the trigger/cause for the effect to happen. In this example, the appropriate trigger would be MobAttacked and/or PlayerAttacked, because the player/mob has to be attacked in order to be poisoned by the sword. Here is how the effect would be coded:

Under the MobAttacked or PlayerAttacked trigger, use an IfThenElse action. Under If, Value1 should be $getEquip($attackingPlayer), the operator should be ==, and Value2 should be GreenEnergySword. Under Then, use a Command, and write '/effect give $entityId poison'. Nothing has to be written under Else.

## Functions

Functions, when given an input, will give an output in return. They can be used in Commands or in IfThenElse conditions. For example, if the $getSpeed function is used with the variable $player (written in-game as $getSpeed($player)), then the input will be the player, and the output will be their speed.

For a full list of functions, go to the Functions page.

### How to Use Functions

To use functions, the player has to know the desired input and output. For example, a player can code a store using $getGold to determine how much gold the player has. The input is the player and the output is their gold. To trigger the functions, players can use InteractBuilding (if the store was used by pressing Emergency Buttons). Here is how the sale would be coded:

Under the InteractBuilding trigger, use an IfThenElse action. Under If, Value1 should be $getGold($player), the operator should be >=, and Value2 should be the price of the object you are selling. Under Then, use a Command, and write '/give $player (item you want to give) (number of item)'. Also, write '/gold lose $player (price of item)' to take away gold. If this is not added, players can get free items. Under Else, it is useful to put some kind of /chat command to tell the player they did not have enough gold (the Else happened instead of the Then because their gold was less than the required amount, instead of more than or equal to).

It is important to have >= (less than or equal to) as the operator. If the operator is == (equal to), it will only give players the item if their gold is the exact same as the price. With >=, they can purchase the item if their gold is higher than the price.

## Timers

Timer:start

Timer:tick

Timer:end

**Unlimited Timer actions per trigger**

Timers have options that are name, duration, or tick. To make a timer do something when it starts, press add new trigger (the + sign) and there will be 3 more triggers, Timer:[TimerName]:start, Timer:[TimerName]:tick, and Timer:[TimerName]:end. These triggers are for when the timer starts, is ticking, and ends. They are just like any other trigger, you can add commands, IfThenElse, and even other timers.

## Actions

There are 3 actions in command blocks. They are commands, IfThenElse and timer.

### Commands

Only one command action can be used per trigger.

Runs a command or a series of commands. Visit /help to learn how to use commands.

### IfThenElse

Unlimited IfThenElse actions per trigger.

IfThenElse checks when a value is equal to, less than, greater than, or not equal to another value. If the value is equal to, less than, greater than, or not equal the input then the trigger in the "then" part will run, otherwise the trigger in "else" will run.