Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

test_level.gd 2.0 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. extends BaseLevel
  2. class_name TestLevel
  3. export var init_yarn_script : Resource
  4. func _ready():
  5. yarnRunner.add_command("Spawn", funcref(self, "spawn"))
  6. yarnRunner.add_command("EnableTrigger", funcref(self, "enable_trigger"))
  7. yarnRunner.add_command("Scene", funcref(self, "scene"))
  8. EventDispatcher.connect("trigger_script", self, "trigger_script")
  9. Controller.hud.show()
  10. Controller.player_infos.reset()
  11. trigger_script(init_yarn_script)
  12. func spawn(args):
  13. yield(get_tree(), "idle_frame")
  14. if args.size() < 1:
  15. printerr("Spawn command take at least one parameter for target")
  16. return
  17. var spawner = get_node("Spawners/" + args[0])
  18. if spawner != null and spawner.has_method("spawn"):
  19. spawner.spawn()
  20. else:
  21. print("spawner " + args[0] + " not found or not compatible")
  22. func enable_trigger(args):
  23. yield(get_tree(), "idle_frame")
  24. if args.size() < 1:
  25. printerr("EnableTrigger command take at least one parameter for target")
  26. return
  27. var trigger = get_node("Triggers/" + args[0])
  28. if trigger != null and trigger.has_method("enable"):
  29. trigger.enable()
  30. print("trigger " + args[0] + " enabled")
  31. else:
  32. print("trigger " + args[0] + " not found or not compatible")
  33. func trigger_script(yarn_script):
  34. print("script triggered")
  35. yarnRunner.say_func = funcref(Controller.speech_panel.text, "on_new_line")
  36. yarnRunner.choices_func = funcref(Controller.speech_panel.choices, "on_choices")
  37. Controller.speech_panel.show()
  38. Controller.player_input_enabled = false
  39. yarnRunner.yarnScript = yarn_script
  40. yield(yarnRunner.run_all(), "completed")
  41. Controller.speech_panel.hide()
  42. Controller.player_input_enabled = true
  43. func scene(args):
  44. yield(get_tree(), "idle_frame")
  45. if args.size() < 1:
  46. printerr("Scene command take at least one parameter for target")
  47. return
  48. print("Request new scene : " + args[0])
  49. emit_signal("request_new_scene", args[0])
  50. func _exit_tree():
  51. Controller.hud.hide()
  52. Controller.speech_panel.hide()
  53. func _on_Switch_switch(activated):
  54. $DirectionalLight.light_energy = activated if 1 else 0