Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Getting Started

brunosxs edited this page Jun 10, 2017 · 14 revisions

Kinda 123...456-ish

Understanding how SMRT works

A text is a single message that can be edited with different parameters

A dialog is a collection of texts.

A chapter is a collection of dialogs. This is really useful for modularizing dialogs and chars. If a character has a dialog "smalltalk "in chapter "Intro", it can have a completely different dialog, also called "smalltalk" in another chapter, if you keep the same schema.

1. Installing and enabling it

Needs Godot 2.1 or newer

On your project's root, create an "addons" folder Copy the contents of SMRT-Godot's repo /addons to your project's /addons folder

Open your project in Godot, go to Project Settings, click on the Plugins tab and enable SMRT

2. Insert the node SMRT-Dialog

It must be a direct child of a CanvasLayer Set its position to (0,0)

3. Configure things

Really simple step, having the SMRT-Dialog node selected(it extends from a Path9frame)

  1. Set a language file for the dialog system to read from
  2. Select a new *.wav file to replace the default beep sound.
  3. Select a font
  4. Set the font size
  5. Select or create a SpriteFrames that will be used by SMRT for displaying a cool image of the characters speaking
  6. Select a texture for the visual signal that SMRT is waiting for the player input to continue
  7. The proportion for the height of the dialog frame based on the viewport resolution
  8. Change anything you wish

SMRT is SMART, it doesn't care nor make you care about resolution or screen position , it will always stay on the screen, in three possible configurations so you don't have to mess with pixel-precise positions:

  • Top of the screen
  • Middle of the screen
  • Bottom of the screen

This parameter is read from the language file you should have loaded before.

4. Open the editor to create your chapters/dialogs/texts

If everything went ok, you should see the button to open the SMRT-Editor.

For more info about the editor, go to the [SMRT-Editor's page] (https://github.com/brunosxs/SMRT-Godot/wiki/SMRT-Editor)

  1. Main menu: Create/Save/Load a new file
  2. Chapter Select
  3. Dialog Select
  4. Text Select
  5. Options related for each text
  6. The actual message that will be displayed.
  7. Options related to the question/answer system.

5. Call it

The basic syntax is: SMRT.show_text(chapter, dialog, start_at)

The third parameter is optional, it lets you choose where to start the dialog.

Easy-peasy:

  • Simplest of examples:

get_node("CanvasLayer/dialog").show_text("INTRO", "OLD MAN") (Taken from the examples file)

  • A character interacts with another(preventing that the event fires itself over and over):
onready var SMRT = get_node("CanvasLayer/dialog")
func contact(body):
	if body extends load("res://examples/interact/character.gd"):
		if is_player and can_talk and not body.is_player:
			can_talk = false
			print("NAME OF THE BODY: ",body.get_name())
			SMRT.show_text(body.chapter, body.dialog, body.start_at)
			yield(SMRT, "finished_dialog")
			area.connect("body_exit", self, "no_contact")
	
func no_contact(body):
	if body extends load("res://examples/interact/character.gd"):
		if is_player and not can_talk:
 			can_talk = true
 			area.disconnect("body_exit", self, "no_contact")

Code directly taken from the examples

6. Get info from it

SMRT has 2 useful signals:

  • dialog_control(info) By far the most important, it is fired whenever it finishes displaying a single text. The parameter passed is a dictionary with the following info:
answer: if a question was answered, it will give the index of the button selected, otherwise it is null
chapter: the chapter playing
dialog: the dialog
last_text_index: the index of the last text
total_text: the number of texts in the current dialog	

If the player has answered a question, dialog_control is fired optionaly a second time on the same loop, passing the id of the answer selected.

  • finished Fired when an entire dialog finishes(not just a single text box)

8. Tips:

  • Send text directly to SMRT: If you want to show a single message without adding it to the language file, you just need to call show_text(chapter,dialog) with "single_text" as the chapter parameter, and write the string you want to show on the dialog parameter

  • SMRT doesn't work when exported?: See: #2