You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Add shorthand for using singleton string names
This commit is contained in:
@@ -2038,15 +2038,15 @@ void GDScriptInstance::notification(int p_notification, bool p_reversed) {
|
||||
}
|
||||
|
||||
String GDScriptInstance::to_string(bool *r_valid) {
|
||||
if (has_method(CoreStringNames::get_singleton()->_to_string)) {
|
||||
if (has_method(CoreStringName(_to_string))) {
|
||||
Callable::CallError ce;
|
||||
Variant ret = callp(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
|
||||
Variant ret = callp(CoreStringName(_to_string), nullptr, 0, ce);
|
||||
if (ce.error == Callable::CallError::CALL_OK) {
|
||||
if (ret.get_type() != Variant::STRING) {
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
|
||||
ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringName(_to_string) + ", must be a String.");
|
||||
}
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
|
||||
Reference in New Issue
Block a user