# Spleef

Let’s build a chat command that creates a Spleef arena.

## Step 1

Put in an `||player:on chat command||` and rename it to spleef.

``````player.onChat("spleef", function () {

})``````

## Step 2

Place a `||blocks:fill||` in side `||player:on chat command||` to create a layer of lava in the ground between the player position ~0 ~-1 ~0 and ten blocks away north and west ~10 ~-1 ~10.

The `||blocks:fill||` takes two locations in the world and fills that area with Lava. By default, it takes coordinates relative to the player, that is what the ~ means in slash commands.

• ~0 ~-1 ~0 means 0 blocks west, 1 block down (-1 up), 0 block north.
• ~10 ~-1 ~10 means 10 blocks west, 1 block down (-1 up), 10 block north.
``````player.onChat("spleef", function () {
blocks.fill(
LAVA,
pos(0, -1, 0),
pos(10, -1, 10)
)
})``````

## Step 3

Put in another `||blocks:fill||` to create a layer of snow in the air between the player position ~0 ~4 ~0 and ten blocks away north and west ~10 ~4 ~10.

~0 ~4 ~0 means 0 blocks west, 4 block up, 0 block north. ~10 ~4 ~10 means 10 blocks west, 4 block up, 10 block north.

``````player.onChat("spleef", function () {
blocks.fill(
LAVA,
pos(0, -1, 0),
pos(10, -1, 10)
)
blocks.fill(
SNOW,
pos(0, 4, 0),
pos(10, 4, 10)
)
})``````

## Step 4

Go to Minecraft, press t to open the chat and enter spleef.

## Step 5

Add a number parameter to the `||player:on chat command||` called `num1`. In Blocks, click on the (+) symbol to add the parameter. Replace the number 10 with the `||variables:num1||` variable.

So far, the arena created is just 10x10… boring! By using the `||variables:num1||` variable instead, the user can select the size of every game.

``````player.onChat("spleef", function (num1) {
blocks.fill(
LAVA,
pos(0, -1, 0),
pos(num1, -1, num1),
FillOperation.Replace
)
blocks.fill(
SNOW,
pos(0, 4, 0),
pos(num1, 4, num1),
FillOperation.Replace
)
})``````

## Step 6

Got to Minecraft and enter `spleef 25` in the chat.

## Step 7

Place a `||mobs:teleport to position||` at the end to select all players and teleport them to ~num1/2 ~5 ~num1/2.

``````player.onChat("spleef", function (num1) {
blocks.fill(
LAVA,
pos(0, -1, 0),
pos(num1, -1, num1),
FillOperation.Replace
)
blocks.fill(
SNOW,
pos(0, 4, 0),
pos(num1, 4, num1),
FillOperation.Replace
)
mobs.teleportToPosition(
mobs.target(ALL_PLAYERS),
pos(num1 / 2, 5, num1 / 2)
)
})``````

## Step 8

Finally, put in a `||gameplay:set game mode||` to switch all players to survival mode.

``````player.onChat("spleef", function (num1) {
blocks.fill(
LAVA,
pos(0, -1, 0),
pos(num1, -1, num1),
FillOperation.Replace
)
blocks.fill(
SNOW,
pos(0, 4, 0),
pos(num1, 4, num1),
FillOperation.Replace
)
mobs.teleportToPosition(
mobs.target(ALL_PLAYERS),
pos(num1 / 2, 5, num1 / 2)
)
gameplay.setGameMode(
SURVIVAL,
mobs.target(ALL_PLAYERS)
)
})``````