Yes, it is possible to manually search for certain keywords within ZScript. However, this means manually adjusting a for loop inside of ZScript to find the arrangement of letters we're looking for, and I'm pretty positive on ZScript's side, that's one heck of a slowdown.
In case if some don't know what I'm talking about, say I have a sentence "IWantTacos" and I want to find the word "Tacos" within. An official native implementation of this sounds like a much saner and less laggier comparison than manually doing it in a for loop.
(I could be wrong -- there could possibly be no difference, but I can't say for certain. However, this is the VM doing the work instead of the engine so I'm assuming it'd be more performance efficient to have it all done natively and returned.)
[ZScript] String.Search(<string>)
Moderator: GZDoom Developers
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: [ZScript] String.Search(<string>)
I think it's better to add existing IndexOf() and LastIndexOf() functions from C++ FString class to ZScript because they are much more versatile.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: [ZScript] String.Search(<string>)
Whatever works best!
Re: [ZScript] String.Search(<string>)
It's not a big deal to add them. But what will be the next version of ZScript? 2.6?
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] String.Search(<string>)
New functions do not require a new version, only changes that may break existing code. In any case, the ZScript version should be the same as the engine version, the next one would be 3.2
Re: [ZScript] String.Search(<string>)
Added in c56cd24. Both function will return -1 if search string was not found.
Re: [ZScript] String.Search(<string>)
The ZScript.txt file still specifies "2.5" (and was actually a source of confusion when I corrected the version.h comment, Major Cooke thought I changed it to the wrong version).Graf Zahl wrote:New functions do not require a new version, only changes that may break existing code. In any case, the ZScript version should be the same as the engine version, the next one would be 3.2
I didn't bother changing it though since no breaking changes were introduced - as far as I know.