Implementing dictionary operators
This commit is contained in:
@@ -13,7 +13,9 @@ func _ready():
|
||||
var ref = ExampleRef.new()
|
||||
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("test array", $Example.test_array())
|
||||
prints("test dictionary", $Example.test_dictionary())
|
||||
|
||||
# Use properties.
|
||||
prints("custom position is", $Example.group_subgroup_custom_position)
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
script = ExtResource( "1_c326s" )
|
||||
|
||||
[node name="Example" type="Example" parent="."]
|
||||
script = null
|
||||
|
||||
[node name="Label" type="Label" parent="Example"]
|
||||
offset_left = 194.0
|
||||
offset_top = -2.0
|
||||
offset_right = 234.0
|
||||
offset_bottom = 21.0
|
||||
structured_text_bidi_override_options = []
|
||||
script = null
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
@@ -23,9 +20,6 @@ __meta__ = {
|
||||
offset_right = 79.0
|
||||
offset_bottom = 29.0
|
||||
text = "Click me!"
|
||||
script = null
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[connection signal="custom_signal" from="Example" to="." method="_on_Example_custom_signal"]
|
||||
|
||||
@@ -54,7 +54,9 @@ void Example::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("return_something_const"), &Example::return_something_const);
|
||||
ClassDB::bind_method(D_METHOD("return_extended_ref"), &Example::return_extended_ref);
|
||||
ClassDB::bind_method(D_METHOD("extended_ref_checks"), &Example::extended_ref_checks);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("test_array"), &Example::test_array);
|
||||
ClassDB::bind_method(D_METHOD("test_dictionary"), &Example::test_dictionary);
|
||||
|
||||
{
|
||||
MethodInfo mi;
|
||||
@@ -145,6 +147,15 @@ Array Example::test_array() const {
|
||||
return arr;
|
||||
}
|
||||
|
||||
Dictionary Example::test_dictionary() const {
|
||||
Dictionary dict;
|
||||
|
||||
dict["hello"] = "world";
|
||||
dict["foo"] = "bar";
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
||||
// Properties.
|
||||
void Example::set_custom_position(const Vector2 &pos) {
|
||||
custom_position = pos;
|
||||
|
||||
@@ -88,7 +88,9 @@ public:
|
||||
Ref<ExampleRef> extended_ref_checks(Ref<ExampleRef> p_ref) const;
|
||||
Variant varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error);
|
||||
void emit_custom_signal(const String &name, int value);
|
||||
|
||||
Array test_array() const;
|
||||
Dictionary test_dictionary() const;
|
||||
|
||||
// Property.
|
||||
void set_custom_position(const Vector2 &pos);
|
||||
|
||||
Reference in New Issue
Block a user