|
| 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) |
0 commit comments