“Hello, world!” – Easy coding with the Script Editor

Note: you can find an updated version of this tutorial here http://gamefroot.com/knowledgebase/hello-world-displaying-text/

Gamefroot’s Script Editor allows you to easily code instructions for anything in your game. We can create code as simple as making words pop up in our game that say “Hello world!”. Let’s get started.

First, make sure you have an object in your game. For this example, I’m going to use a cool looking shark character from the “Underwater Pack” that I got from the Marketplace. To learn more about getting game assets from the Marketplace, click here.

Now let’s build our script. Click the Script Edit mode button in the top-right corner to open the Script Editor. Here’s what we’re going to make:

hello-world-script2

The first block we will need is an Event block. This will trigger the other blocks to run our code. Click Game Mechanics, then Events, and all the Event blocks will become available. The block we want to use is “When the player presses myself”. Click and drag that block out into the blank workspace.

The next block we need is to display words, so that when the player clicks on the shark, he will say “Hello, world!”. Since these words are text, we want to open the Text tab in the sidebar. Then find the “Print” block, and the “empty text” block, and drag them out into the workspace.

Make sure the two blocks get snapped together, and then snap them inside the event block. To snap blocks together, drag them close to each other until they glow, then release them.

 

We need words to get printed (displayed) on the screen, so we have to type something in the empty slot in the text block. Click on that empty slot, and type the words you want to display.

text-script

Now our script is complete! Click Save in the top-left corner to save this script so we can use it in our game. Give it a name then click Done to return to the level editor.

hello-world-script

Your script can be found in the Scripts tab in the sidebar to the left. Click on your script, and then click on the object you want to become scripted – this will attach the script to that object.

Now preview your game by clicking the Preview button in the top-right corner.

When your game runs and you click on your object, the “Hello, world!” message will pop up. Good job!

Leave a Reply