2021-08-19 17:51:41 +00:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
func _ready():
|
2021-09-26 06:15:01 +00:00
|
|
|
# Bind signals
|
2022-05-04 11:27:08 +00:00
|
|
|
prints("Signal bind")
|
2021-09-26 06:15:01 +00:00
|
|
|
$Button.button_up.connect($Example.emit_custom_signal.bind("Button", 42))
|
2022-05-04 11:27:08 +00:00
|
|
|
|
|
|
|
prints("")
|
|
|
|
|
2022-08-19 07:30:06 +00:00
|
|
|
# To string.
|
|
|
|
prints("To string")
|
|
|
|
prints(" Example --> ", $Example.to_string())
|
|
|
|
prints(" ExampleMin --> ", $Example/ExampleMin.to_string())
|
|
|
|
|
2022-05-04 11:27:08 +00:00
|
|
|
# Call static methods.
|
|
|
|
prints("Static method calls")
|
|
|
|
prints(" static (109)", Example.test_static(9, 100));
|
|
|
|
Example.test_static2();
|
2022-08-19 07:30:06 +00:00
|
|
|
|
|
|
|
# Property list.
|
|
|
|
prints("Property list")
|
|
|
|
$Example.property_from_list = Vector3(100, 200, 300)
|
|
|
|
prints(" property value ", $Example.property_from_list)
|
2022-10-09 06:47:07 +00:00
|
|
|
|
2021-08-19 17:51:41 +00:00
|
|
|
# Call methods.
|
2022-05-04 11:27:08 +00:00
|
|
|
prints("Instance method calls")
|
2021-08-19 17:51:41 +00:00
|
|
|
$Example.simple_func()
|
|
|
|
($Example as Example).simple_const_func() # Force use of ptrcall
|
2022-05-04 11:27:08 +00:00
|
|
|
prints(" returned", $Example.return_something("some string"))
|
|
|
|
prints(" returned const", $Example.return_something_const())
|
2022-12-05 11:04:08 +00:00
|
|
|
var null_ref = $Example.return_empty_ref()
|
|
|
|
prints(" returned empty ref", null_ref)
|
|
|
|
var ret_ref = $Example.return_extended_ref()
|
|
|
|
prints(" returned ref", ret_ref.get_instance_id(), ", id:", ret_ref.get_id())
|
2022-07-20 20:49:08 +00:00
|
|
|
prints(" returned ", $Example.get_v4())
|
2023-01-10 10:48:21 +00:00
|
|
|
prints(" test node argument", $Example.test_node_argument($Example))
|
2022-05-04 11:27:08 +00:00
|
|
|
|
|
|
|
prints("VarArg method calls")
|
2021-09-28 13:49:53 +00:00
|
|
|
var ref = ExampleRef.new()
|
2022-05-04 11:27:08 +00:00
|
|
|
prints(" sending ref: ", ref.get_instance_id(), "returned ref: ", $Example.extended_ref_checks(ref).get_instance_id())
|
|
|
|
prints(" vararg args", $Example.varargs_func("some", "arguments", "to", "test"))
|
|
|
|
prints(" vararg_nv ret", $Example.varargs_func_nv("some", "arguments", "to", "test"))
|
2022-03-29 11:44:07 +00:00
|
|
|
$Example.varargs_func_void("some", "arguments", "to", "test")
|
2021-11-18 03:05:14 +00:00
|
|
|
|
2022-05-04 11:27:08 +00:00
|
|
|
prints("Method calls with default values")
|
|
|
|
prints(" defval (300)", $Example.def_args())
|
|
|
|
prints(" defval (250)", $Example.def_args(50))
|
|
|
|
prints(" defval (150)", $Example.def_args(50, 100))
|
|
|
|
|
|
|
|
prints("Array and Dictionary")
|
|
|
|
prints(" test array", $Example.test_array())
|
2022-09-15 07:33:07 +00:00
|
|
|
prints(" test tarray", $Example.test_tarray())
|
2022-05-04 11:27:08 +00:00
|
|
|
prints(" test dictionary", $Example.test_dictionary())
|
2022-09-15 07:33:07 +00:00
|
|
|
var array: Array[int] = [1, 2, 3]
|
|
|
|
$Example.test_tarray_arg(array)
|
2021-08-19 17:51:41 +00:00
|
|
|
|
2022-11-28 12:47:55 +00:00
|
|
|
prints("String += operator")
|
|
|
|
prints(" test string +=", $Example.test_string_ops())
|
|
|
|
|
|
|
|
prints("WorkerThreadPool")
|
|
|
|
prints(" test worker_thread_pool", $Example.test_workpool_ops())
|
|
|
|
|
|
|
|
prints("PackedArray iterators")
|
|
|
|
prints(" test packed array iterators", $Example.test_vector_ops())
|
|
|
|
|
2022-05-04 11:27:08 +00:00
|
|
|
prints("Properties")
|
|
|
|
prints(" custom position is", $Example.group_subgroup_custom_position)
|
2021-09-15 03:56:20 +00:00
|
|
|
$Example.group_subgroup_custom_position = Vector2(50, 50)
|
2022-05-04 11:27:08 +00:00
|
|
|
prints(" custom position now is", $Example.group_subgroup_custom_position)
|
2021-08-19 17:51:41 +00:00
|
|
|
|
2023-01-10 17:02:46 +00:00
|
|
|
prints("Constants")
|
2022-05-04 11:27:08 +00:00
|
|
|
prints(" FIRST", $Example.FIRST)
|
|
|
|
prints(" ANSWER_TO_EVERYTHING", $Example.ANSWER_TO_EVERYTHING)
|
|
|
|
prints(" CONSTANT_WITHOUT_ENUM", $Example.CONSTANT_WITHOUT_ENUM)
|
2021-08-19 17:51:41 +00:00
|
|
|
|
2022-12-08 05:34:19 +00:00
|
|
|
prints("BitFields")
|
|
|
|
prints(" FLAG_ONE", Example.FLAG_ONE)
|
|
|
|
prints(" FLAG_TWO", Example.FLAG_TWO)
|
|
|
|
prints(" returned BitField", $Example.test_bitfield(0))
|
|
|
|
prints(" returned BitField", $Example.test_bitfield(Example.FLAG_ONE | Example.FLAG_TWO))
|
|
|
|
|
2022-05-29 08:51:33 +00:00
|
|
|
func _on_Example_custom_signal(signal_name, value):
|
|
|
|
prints("Example emitted:", signal_name, value)
|