How to make characters talk with text pop-up windows

From Platinum Arts Sandbox Free 3D Game Maker
Jump to: navigation, search

This tutorial will teach you how to make basic GUI code. This code basically allows NPCs and stuff to talk.

//Test GUI
newgui dialogue1 [
       guitext "Hello, this is where the text is entered." chat
]   "Hello, this is the title"

As you can see above, everything is written in a neat fashion.

  • newgui - Represents a new GUI window, where your character will speak.
  • dialogue1 - The name of your gui window. This is followed by an open bracket to let the game know we are going to start adding the text that the character will say.
  • guitext - Let's the game know that we are about to add a line of text for the character to say. Always make sure to put quotations (" ") around the text. Place "chat" without quotations at the end of the line to let the computer know the line is done.
  • The last line contains the final two parts - the closing bracket indicating that it is the end of the text, and the title that you want to have appear at the top of your GUI window.

Let's move on to something more advanced.

//Test GUI
newgui dialogue2 [
	guitext "First line of text!" chat
	guitext "Second line of text!" chat
	guitext "Third line of text!." chat	
]   "Lines of text."

In dialogue2 (above), we have three lines of text. Each guitext entry will appear on its own line. This gives us more room for characters to give big speeches and longer descriptions.

//Test GUI
newgui dialogue3 [
	guitext "^fs^f0Hello, I am green text^fr" chat
]   "Green Text"

Adding color tags allows you to color text

  • ^fs starts text coloring
  • ^f0 tells the game what color to use, 0 being green.
  • ^fr ends text coloring

Below you can see how we can change color of the text as often as we want even in one line of text.

//Test GUI
newgui dialogue4 [
	guitext "^fs^f0Hello^fr, I am ^fs^f1blue^fr, no wait! ^fs^f3RED!^fr." chat
]   "Colored Text"

Here is the full list of colors and color commands that you can use in your text.

  • ^f0 - Green
  • ^f1 - Blue
  • ^f2 - Yellow
  • ^f3 - Red
  • ^f4 - Gray
  • ^f5 - Magneta
  • ^f6 - Oramge
  • ^f7 - White
  • ^fA - Apricot
  • ^fB - Brown
  • ^fC - Corn
  • ^fD - Dodger Blue
  • ^fE - Emerald
  • ^fF - Fuchsia
  • ^fG - Gold
  • ^fH - Heliotrope
  • ^fI - Indigo
  • ^fJ - Jade
  • ^fK - Khaki
  • ^fL - Lemon
  • ^fM - Mint
  • ^fN - Navajo White
  • ^fO - Olive
  • ^fP - Pink
  • ^fR - Rose
  • ^fS - Silver
  • ^fT - Turqoise
  • ^fU - Ultramarine
  • ^fV - Violet
  • ^fW - Wheat
  • ^fY - Yellow
  • ^fZ - Zinnwaldite
  • ^fs - Start of Text
  • ^fr - End of Text

These allow for a combination of brilliant colors if used in the correct manner. Next I will show you how to execute your GUI, and make an item for your map.

//Dialogue Triggers
level_trigger_1 = [showgui dialogue1; sound $select]

The level trigger chooses which tag your NPC will have. In the example, it tells the game to show dialogue1 and to play a sound.

//Item Triggers
level_trigger_2 = [jumpvel 600; sound $eatapple; showgui eatapple; echo "You've eaten an apple! You can now jump HIGHER!"]

As you can see here, this is a trigger you'd most likely assign to an item. There is a lot going on in that one line so let's break it down. To start, each command is separated by a semi-colon so that the game knows where one begins and the next ends. When this trigger is activated, the following happens:

  • jumpvel 600; - Increase the player's jump velocity
  • sound $eatapple; - Play the sound $eatapple
  • showgui eatapple; - Show a GUI named eatapple
  • echo "You've eaten an apple! You can now jump HIGHER!" - Display text in the top left corner

Mixing these unique functions can make for an exciting map. We hope this tutorial gave you new tools and some new ideas for your next Sandbox project.