main.gd 428 B

123456789101112131415161718
  1. extends Node
  2. const Chat = preload("res://chat.gd")
  3. func _ready():
  4. var p1 = Chat.new()
  5. var p2 = Chat.new()
  6. add_child(p1)
  7. add_child(p2)
  8. # Wait a second and send message from P1
  9. yield(get_tree().create_timer(1), "timeout")
  10. p1.send_message("Hi from %s" % String(p1.get_path()))
  11. # Wait a second and send message from P2
  12. yield(get_tree().create_timer(1), "timeout")
  13. p2.send_message("Hi from %s" % String(p2.get_path()))