diff --git a/src/common/scripting/interface/stringformat.cpp b/src/common/scripting/interface/stringformat.cpp index 4bfe34ff6..77ce54ed6 100644 --- a/src/common/scripting/interface/stringformat.cpp +++ b/src/common/scripting/interface/stringformat.cpp @@ -578,6 +578,34 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, StripRight, StringStripRight) return 0; } +static void StringStripLeft(FString* self, const FString& junk) +{ + if (junk.IsNotEmpty()) self->StripLeft(junk); + else self->StripLeft(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, StripLeft, StringStripLeft) +{ + PARAM_SELF_STRUCT_PROLOGUE(FString); + PARAM_STRING(junk); + StringStripLeft(self, junk); + return 0; +} + +static void StringStripLeftRight(FString* self, const FString& junk) +{ + if (junk.IsNotEmpty()) self->StripLeftRight(junk); + else self->StripLeftRight(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, StripLeftRight, StringStripLeftRight) +{ + PARAM_SELF_STRUCT_PROLOGUE(FString); + PARAM_STRING(junk); + StringStripLeftRight(self, junk); + return 0; +} + static void StringSplit(FString* self, TArray* tokens, const FString& delimiter, int keepEmpty) { self->Split(*tokens, delimiter, static_cast(keepEmpty)); diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index cd2269661..ea6440bbc 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -881,7 +881,9 @@ struct StringStruct native native int CodePointCount() const; native int, int GetNextCodePoint(int position) const; native void Substitute(String str, String replace); + native void StripLeft(String junk = ""); native void StripRight(String junk = ""); + native void StripLeftRight(String junk = ""); } struct Translation version("2.4")