main.gd 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. extends Node
  2. func _ready():
  3. # Bind signals
  4. prints("Signal bind")
  5. $Button.button_up.connect($Example.emit_custom_signal.bind("Button", 42))
  6. prints("")
  7. # To string.
  8. prints("To string")
  9. prints(" Example --> ", $Example.to_string())
  10. prints(" ExampleMin --> ", $Example/ExampleMin.to_string())
  11. # Call static methods.
  12. prints("Static method calls")
  13. prints(" static (109)", Example.test_static(9, 100));
  14. Example.test_static2();
  15. # Property list.
  16. prints("Property list")
  17. $Example.property_from_list = Vector3(100, 200, 300)
  18. prints(" property value ", $Example.property_from_list)
  19. # Call methods.
  20. prints("Instance method calls")
  21. $Example.simple_func()
  22. ($Example as Example).simple_const_func() # Force use of ptrcall
  23. prints(" returned", $Example.return_something("some string"))
  24. prints(" returned const", $Example.return_something_const())
  25. var null_ref = $Example.return_empty_ref()
  26. prints(" returned empty ref", null_ref)
  27. var ret_ref = $Example.return_extended_ref()
  28. prints(" returned ref", ret_ref.get_instance_id(), ", id:", ret_ref.get_id())
  29. prints(" returned ", $Example.get_v4())
  30. prints(" test node argument", $Example.test_node_argument($Example))
  31. prints("VarArg method calls")
  32. var ref = ExampleRef.new()
  33. prints(" sending ref: ", ref.get_instance_id(), "returned ref: ", $Example.extended_ref_checks(ref).get_instance_id())
  34. prints(" vararg args", $Example.varargs_func("some", "arguments", "to", "test"))
  35. prints(" vararg_nv ret", $Example.varargs_func_nv("some", "arguments", "to", "test"))
  36. $Example.varargs_func_void("some", "arguments", "to", "test")
  37. prints("Method calls with default values")
  38. prints(" defval (300)", $Example.def_args())
  39. prints(" defval (250)", $Example.def_args(50))
  40. prints(" defval (150)", $Example.def_args(50, 100))
  41. prints("Array and Dictionary")
  42. prints(" test array", $Example.test_array())
  43. prints(" test tarray", $Example.test_tarray())
  44. prints(" test dictionary", $Example.test_dictionary())
  45. var array: Array[int] = [1, 2, 3]
  46. $Example.test_tarray_arg(array)
  47. prints("String += operator")
  48. prints(" test string +=", $Example.test_string_ops())
  49. prints("PackedArray iterators")
  50. prints(" test packed array iterators", $Example.test_vector_ops())
  51. prints("Properties")
  52. prints(" custom position is", $Example.group_subgroup_custom_position)
  53. $Example.group_subgroup_custom_position = Vector2(50, 50)
  54. prints(" custom position now is", $Example.group_subgroup_custom_position)
  55. prints("Constants")
  56. prints(" FIRST", $Example.FIRST)
  57. prints(" ANSWER_TO_EVERYTHING", $Example.ANSWER_TO_EVERYTHING)
  58. prints(" CONSTANT_WITHOUT_ENUM", $Example.CONSTANT_WITHOUT_ENUM)
  59. prints("BitFields")
  60. prints(" FLAG_ONE", Example.FLAG_ONE)
  61. prints(" FLAG_TWO", Example.FLAG_TWO)
  62. prints(" returned BitField", $Example.test_bitfield(0))
  63. prints(" returned BitField", $Example.test_bitfield(Example.FLAG_ONE | Example.FLAG_TWO))
  64. func _on_Example_custom_signal(signal_name, value):
  65. prints("Example emitted:", signal_name, value)