Log in

Tutorial 0: Spinny Shooter

Welcome to Mast, a competitive programming game where players compete to create the best autonomous fighting spaceships.

You can find documentation on gameplay and scripting at https://propslam.com/mast/docs/.


In this tutorial, we'll be making a very basic ship that simply spins for three seconds at the start and shoots continuously.

Sign up and Login

If you haven't already, you should create an account. Click the "Sign In" and then the "Don't have an account?" buttons to do so.

Sign In and click the "Ship Editor" button to get to the Ship Editor screen.

The Ship Editor

The Ship Editor is where you will create and modify your ships.


The first view we see in the Ship Editor is the Blueprint View.

The Blueprint View allows you to place a variety of different parts to create the structure of your ship.

On the left you see a list of parts you can use.

Above that, you can see your budget. Every part has an associated price. The total cost of your ship must remain under this budget.

On the right, you have a list of your current ships. You also have the ability to switch between Blueprint and Script Views here. We'll get back to that later.

You may have noticed that there's already a part placed in the blueprint. That part is the Brain, and it's the most important part on your ship.

When the brain is destroyed, the rest of the ship is destroyed with it.

You start a match with three ships. When all of your ships are destroyed, you lose the match.

The Brain can't be moved or deleted.

Ship Editor Controls

Creating our ship

Let's get started creating our ship.

Place down 8 Hull blocks surrounding the Brain.

Add two Thrusters in opposite corners so that our ship can spin.

Finally, add four Turrets in the middle of each side.

Make sure to rotate parts so that they're facing the right direction using R {R}.

Two parts are connected when there's a light blue circle between them.


Naming parts

Before we can move on to writing the code to control our ship, we need to give some of the parts names.

Right Click {RMB} on a part to give it a name, pressing Enter {Enter} to save it.

Naming a part allows you to reference it from inside the ship's Script.

Let's name the two Thrusters "thruster1" and "thruster2".

We'll name the four Turrets "turret1", "turret2", "turret3", and "turret4".

Names can be anything, as long as they are valid Lua variable names.

This means they can be any combination of letters, numbers, and underscores. Names cannot begin with a number or contain spaces.

The other parts don't need names because we're not going to be referencing them in the script.

[img of ship in blueprint with part names here]

Saving your ship

Take a moment here to save your ship. Type in a name for your ship like "Spinny Shooter" in the top right corner of the screen and click the Save button.

Writing your ship's Script

Without further ado, let's get started writing some code to control our ship.

Click on the Script button in the bottom right corner of the screen to switch to Script View.

You can switch back and forth between Blueprint and Script views whenever you want.

Let's start with a trope. Enter the following script:

function Start()
    print("Hello world!")

Statements inside the Start() function get executed sequentially once at the beginning of every match.

The print() function allows you to output text to the Print Panel during a match.

Let's see that in action.

Save your ship again, then click the big TEST button in the bottom right corner of the screen.

Expand the Print Panel located in the bottom middle of the screen by clicking on it. You should see the phrase "Hello world!".

[img of ship in testing with print panel expanded, "Hello world!" displayed]

Press Escape {ESCAPE} to open the menu, and click Back to Ship Editor to get back to the Ship Editor.

Now let's use the Thrusters to make our ship spin.

Change the script as follows:

function Start()

Now instead of printing out "Hello world!" in the beginning, we're telling our thrusters to start thrusting at 100% power.

We do this using the SetThrust method. Most parts have various methods you can use to control them or get information from them.

You can see a list of the different methods and how to use them in the Mast documentation.

A method's usage is explained by its "signature". Let's look at the signature for SetThrust:

void :SetThrust(float ratio)

The format of a signature is:

[return_type] :MethodName(param1, param2, ...)

In this case, SetThrust returns nothing, so its return type is "void". SetThrust takes one parameter, of type "float". A "float" is simply a number.

The "ratio" float parameter must be between 0 and 1, where 0 is no thrust and 1 is full thrust. You can see this explained in the method's description in the documentation.

Let's test the ship again. Save your ship, and click that big TEST button again. You should see your ship spinning in place. Progress!

Head back to the editor, and let's get those Turrets firing.

Change the script as follows:

function Start()

function Update()

You should notice that we have a new function now, called Update().

The Update function simply gets executed many times per second during gameplay.

Most of your code will probably be done inside the Update function.

Here, we're simply telling our turrets to fire as often as possible by calling their :Fire() method inside Update().

Test this ship again, and it should now be firing as well as spinning in place.

[gif of spinning and shooting ship]

Finally, let's make the Thrusters stop thrusting after three seconds.

We should do this so that our ship doesn't keep spinning faster and faster until the match ends.

Change the script as follows:

function Start()

function Update()

    if time() > 3 then

We've added something called an "if statement" (also known as a "conditional branch") to the Update() function.

Sometimes you don't want code to execute until a certain condition is met.

In this case, we don't want the thrusters to stop firing until three seconds have elapsed.

We check to see how much time has elapsed using the time() function, which returns the time elapsed since the start of the round in seconds.

Then we check if that duration is greater than 3, and if it is, we turn off our Thrusters by setting their thrust to zero.

Save your ship and test it again. You should see the thrusters go for three seconds and then stop.


And that's it! You've made your first ship. Head back to the main menu, and let's dive into Battle against other players.

Click the "To Battle" button. A dialog will come up that allows you to select which three ships you want to send into battle.

Since we only have one ship, simply select it three times.

[img of Spinny Shooter selected ships]

Now go ahead and enter battle. A random player will be selected for you to fight against.

Each match goes until either one player's ships are destroyed or the time limit at the top expires.

Where to go from here

I hope this tutorial has given you enough information to get started playing Mast.

If you're an absolutely beginner to programming, I'd recommend that you read up on the Lua programming language in general.

Things should become a little more clear once you understand the basics of the language.

You can check out the "Programming in Lua" tutorial here: https://www.lua.org/pil/1.html