Allow booleanization of all types
We now allow booleanization of all types. This means that empty versions
of all types now evaluate to false. So a Vector2(0,0), Dictionary(),
etc.
This allows you to write GDScript like:
if not Dictionary():
print("Empty dict")
Booleanization can now also no longer fail. There is no more valid flag,
this changes Variant and GDNative API.
This commit is contained in:
@@ -480,10 +480,9 @@ godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const g
|
||||
return self->hash_compare(*other);
|
||||
}
|
||||
|
||||
godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self, godot_bool *r_valid) {
|
||||
godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self) {
|
||||
const Variant *self = (const Variant *)p_self;
|
||||
bool &valid = *r_valid;
|
||||
return self->booleanize(valid);
|
||||
return self->booleanize();
|
||||
}
|
||||
|
||||
void GDAPI godot_variant_destroy(godot_variant *p_self) {
|
||||
|
||||
Reference in New Issue
Block a user