Skip to content

Commit 04d8fbb

Browse files
authored
Merge pull request #247 from theludovyc/fix#242_add_doc_example
fix #242 add full doc example
2 parents 07527b0 + c33a201 commit 04d8fbb

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

Test/TestDocExample/Timeline.rk

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
hello_world
2+
character gd "Godot"
3+
character emy "Emily"
4+
"<gd.name> and <emy.name> meet"
5+
menu menu_emily:
6+
"Wait"
7+
"Talk to emily" > gd_start
8+
emy_start:
9+
gd.name = emy "Hello, what is your name ?" ? "<gd.name>"
10+
"Oh, your name is <gd.name> !"
11+
gd_start:
12+
gd "Hello <emy.name>, how are you ?"
13+
menu end:
14+
"end"
15+
"replay" > first_dialogue
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
extends Node
2+
3+
const file_path = "res://Test/TestDocExample/Timeline.rk"
4+
5+
func _ready():
6+
Rakugo.add_custom_regex("HW", "^hello_world$")
7+
8+
Rakugo.sg_custom_regex.connect(_on_custom_regex)
9+
Rakugo.sg_say.connect(_on_say)
10+
Rakugo.sg_step.connect(_on_step)
11+
Rakugo.sg_ask.connect(_on_ask)
12+
Rakugo.sg_menu.connect(_on_menu)
13+
14+
Rakugo.parse_and_execute_script(file_path)
15+
16+
func _on_say(character:Dictionary, text:String):
17+
prints("say", character.get("name", "null"), text)
18+
19+
func _on_step():
20+
prints("Press 'Enter' to continue...")
21+
22+
func _on_ask(character:Dictionary, question:String, default_answer:String):
23+
prints("ask", character.get("name", "null"), question, default_answer)
24+
25+
func _on_menu(choices:Array):
26+
prints("menu", choices)
27+
28+
func _on_custom_regex(key:String, result:RegExMatch):
29+
prints("custom regex", key, result.strings)
30+
31+
func _process(delta):
32+
if Rakugo.is_waiting_step() and Input.is_action_just_pressed("ui_accept"):
33+
Rakugo.do_step()
34+
35+
if Rakugo.is_waiting_ask_return() and Input.is_action_just_pressed("ui_up"):
36+
Rakugo.ask_return("Bob")
37+
38+
if Rakugo.is_waiting_menu_return() and Input.is_action_just_pressed("ui_down"):
39+
Rakugo.menu_return(0)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://c565ya7cc00bl"]
2+
3+
[ext_resource type="Script" path="res://Test/TestDocExample/test_doc_example.gd" id="1_tix6y"]
4+
5+
[node name="TestDocExample" type="Node"]
6+
script = ExtResource("1_tix6y")

0 commit comments

Comments
 (0)