The first run

We’d like to test out what we have done so far, but first we need to tell Escoria what to do when a new game starts.

Our first ESC script

This is done using ESC, the integrated Escoria scripting language.

While you could use GDscript (or other languages supported by Godot) directly, we added ESC as a specific language for adventure games, so very typical game commands (like making a character speak, letting them walk across the room, etc.) are very easy to use.

The game start-up itself is also coordinated using an ESC script.

Scripts are plain text files with an “.esc” extension, created in any text editor you choose to use. Create a new ESC script which will be our main game script and call it “game.esc”. Switch to Godot’s Editor tab and select “New Text File” from the “File” menu:

Selecting New Text File from the File menu

Save the new file as “game.esc” in your root game folder:

Saving the file as game.esc

This will open the new script directly in the editor.

ESC scripts are built-up using “Events” and “Commands”.

An ESC Event starts with the “:” character and is followed by the name of the event.

There are several special names for events which you will learn later on. One special event name is called newgame and is run when the player clicks on the “New Game” button in the main menu.

Hint

There is also a special event called setup. This is related to the order things happen in more complex game rooms and is not necessary for all scripts. It can be ignored for now.

We basically just want Escoria to switch to our pub scene. For this, we can use the command change_scene. This command expects the path to the target scene as a parameter.

That’s easy to do in Godot: Just select the pub scene in the file tree, right click it and select “Copy Path”:

Context menu shown when right clicking the pub scene file

Add the following to the ESC script game.esc:

:newgame

change_scene res://rooms/pub/pub.tscn

Hint

If you had saved the scene using a name other than “pub.tscn” (e.g. “room1” instead of “pub.tscn”), the change_scene command is where you would need to use that filename.

But what should happen when the game starts before the main menu is shown?

Well, that’s also handled by this script using an “init” event.

You could add introduction sequences, studio logos, etc. For the moment, we only want to show the main menu.

(Further evidence of Escoria being very adaptable to your specific game’s needs!)

Thus, we don’t default to any main menu scene by default. We’ve added a stock main menu for convenience, though, which we can load now.

Add this code:

:init

show_menu main

This instructs the installed UI addon to show the main menu.

The complete file “game.esc” should look like this now:

:init

show_menu main

:newgame

change_scene res://rooms/pub/pub.tscn

Now that we have our game script ready, we need to set it in the Escoria project settings in the “Game Start Script” parameter in the “Main” category.

Hint

ESC files aren’t directly shown in the file explorer as they’re not recognized as Godot resource files (as of the time this was written). As an alternative to copying the path to the ESC file, you can right click the file in the editor:

The context menu shown when the script game.esc is right clicked in th editor.

The setting should look like this.

The parameter Game Start Script set to res://game.esc

Starting the game

Now you’re ready to start the game. Click on Godot’s run icon to do so.

The start game button shaped like a triangle

Click on “New Game” in the main menu and check out your character walking around in the new room!

Slowing Graham down

As you can see, Graham is pretty much running through the pub. Also, he looks a bit like he’s skating through it.

So we should make him walk slower and at the same time animate him faster.

To achieve this, go back to the character and select the ESCPlayer node and set the Speed parameter to 150. Additionally, select the AnimatedSprite node and set the Speed scale parameter to 1.8.

Try starting the game again and watch Graham walk much more naturally.

Let’s make the room more interactive.