From 7b98fdb910917a54d5459fd3f732867296332e0e Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 25 Aug 2017 15:09:18 +0300 Subject: [PATCH] Added ToInt() and ToDouble() functions to ZScript string https://forum.zdoom.org/viewtopic.php?t=57678 --- src/scripting/thingdef_data.cpp | 13 +++++++++++++ wadsrc/static/zscript/base.txt | 2 ++ 2 files changed, 15 insertions(+) diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 274c865bf9..5f4898b369 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -1280,3 +1280,16 @@ DEFINE_ACTION_FUNCTION(FStringStruct, ToLower) self->ToLower(); return 0; } + +DEFINE_ACTION_FUNCTION(FStringStruct, ToInt) +{ + PARAM_SELF_STRUCT_PROLOGUE(FString); + PARAM_INT_DEF(base); + ACTION_RETURN_INT(self->ToLong(base)); +} + +DEFINE_ACTION_FUNCTION(FStringStruct, ToDouble) +{ + PARAM_SELF_STRUCT_PROLOGUE(FString); + ACTION_RETURN_FLOAT(self->ToDouble()); +} diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index e3f453fca1..f74c83e929 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -664,6 +664,8 @@ struct StringStruct native native int LastIndexOf(String substr) const; native void ToUpper(); native void ToLower(); + native int ToInt(int base = 0) const; + native double ToDouble() const; } class SectorEffect : Thinker native