Skip to content

Commit

Permalink
Added IndexOf() and LastIndexOf() functions to ZScript string type
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-lysiuk committed Jul 22, 2017
1 parent ebd20da commit c56cd24
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/scripting/thingdef_data.cpp
Expand Up @@ -1252,3 +1252,18 @@ DEFINE_ACTION_FUNCTION(FStringStruct, Filter)
ACTION_RETURN_STRING(strbin1(*self));
}

DEFINE_ACTION_FUNCTION(FStringStruct, IndexOf)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr);
PARAM_INT_DEF(startIndex);
ACTION_RETURN_INT(self->IndexOf(substr, startIndex));
}

DEFINE_ACTION_FUNCTION(FStringStruct, LastIndexOf)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr);
ACTION_RETURN_INT(self->LastIndexOf(substr));
}

2 changes: 2 additions & 0 deletions wadsrc/static/zscript/base.txt
Expand Up @@ -656,6 +656,8 @@ struct StringStruct native
native String CharAt(int pos) const;
native int CharCodeAt(int pos) const;
native String Filter();
native int IndexOf(String substr, int startIndex = 0) const;
native int LastIndexOf(String substr) const;
}

class SectorEffect : Thinker native
Expand Down

0 comments on commit c56cd24

Please sign in to comment.