diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index 0ab56049f1..b51e051e8c 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -442,6 +442,15 @@ bool Squirrel::CallStringMethodStrdup(HSQOBJECT instance, const char *method_nam return true; } +bool Squirrel::CallStringMethod(HSQOBJECT instance, const char *method_name, std::string *res, int suspend) +{ + HSQOBJECT ret; + if (!this->CallMethod(instance, method_name, &ret, suspend)) return false; + if (ret._type != OT_STRING) return false; + *res = StrMakeValid(ObjectToString(&ret)); + return true; +} + bool Squirrel::CallIntegerMethod(HSQOBJECT instance, const char *method_name, int *res, int suspend) { HSQOBJECT ret; diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp index 444e8a3a0d..77cff710b6 100644 --- a/src/script/squirrel.hpp +++ b/src/script/squirrel.hpp @@ -160,6 +160,7 @@ public: bool CallMethod(HSQOBJECT instance, const char *method_name, HSQOBJECT *ret, int suspend); bool CallMethod(HSQOBJECT instance, const char *method_name, int suspend) { return this->CallMethod(instance, method_name, nullptr, suspend); } bool CallStringMethodStrdup(HSQOBJECT instance, const char *method_name, const char **res, int suspend); + bool CallStringMethod(HSQOBJECT instance, const char *method_name, const std::string *res, int suspend); bool CallIntegerMethod(HSQOBJECT instance, const char *method_name, int *res, int suspend); bool CallBoolMethod(HSQOBJECT instance, const char *method_name, bool *res, int suspend);