mirror of
https://github.com/yeslayla/simple-dialogue.git
synced 2025-09-13 19:43:47 +02:00
Initial commit
This commit is contained in:
38
addons/simple_dialogue/samples/minimal/minimal.gd
Normal file
38
addons/simple_dialogue/samples/minimal/minimal.gd
Normal file
@ -0,0 +1,38 @@
|
||||
extends Node
|
||||
|
||||
var timeline = STimeline.new("res://addons/simple_dialogue/samples/sample.yaml")
|
||||
var event : SEvent
|
||||
export var autoDecide : int = 1
|
||||
|
||||
func _process(_delta):
|
||||
if(Input.is_action_just_pressed("ui_accept")):
|
||||
|
||||
# Check for a choice before reading the timeline
|
||||
# using `STimeline.is_choice()`
|
||||
if timeline.is_choice():
|
||||
|
||||
# You can utilize `STimeline.get_choices()` to return
|
||||
# an array with all choices as strings in order
|
||||
|
||||
# This sample uses the `autoDecide` variable for every
|
||||
# choice
|
||||
print("You: ", timeline.get_choices()[autoDecide])
|
||||
|
||||
# Use `STimeline.make_choice(int)` to make a choice
|
||||
# and load that choice's events
|
||||
timeline.make_choice(autoDecide)
|
||||
return
|
||||
|
||||
# Use `STimeline.read()` to get the next SEvent
|
||||
# in a dialogue timeline
|
||||
event = timeline.read()
|
||||
|
||||
# The primary properties of a SEvent is
|
||||
# `name`, `message`, and `portrait`
|
||||
if event:
|
||||
print(event.name,": ", event.message)
|
||||
|
||||
# When STimeline.read() returns null, the timeline has
|
||||
# completed and you can exit the dialogue
|
||||
if event == null:
|
||||
get_tree().quit()
|
6
addons/simple_dialogue/samples/minimal/minimal.tscn
Normal file
6
addons/simple_dialogue/samples/minimal/minimal.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/simple_dialouge/samples/minimal/minimal.gd" type="Script" id=1]
|
||||
|
||||
[node name="Simple Dialogue Minimal Example" type="Node"]
|
||||
script = ExtResource( 1 )
|
Reference in New Issue
Block a user