Community Forum

Issue with Utils.splitString(".","test.tester")

Forum Overview >> Scripting

Created22.06.2009 02:36

Michael Pillkahn (Unknown) 22.06.2009 02:41
last week i have trouble with:

self.test = "ein wert"
self.testb = 0
self.savingvals = "self.test self.testb";
local a = Utils.splitString(" ",self.savingvals);
local b = Utils.splitString(".",a[1])

the split with " " works, but the split with . didn't

Michael Pillkahn (Unknown) 22.06.2009 02:47
oh i forgott, self.test i need it to saving
savestring = savestring..''

Stefan Geiger - GIANTS Software 22.06.2009 12:24
The problem is, that Utils.splitString internally uses string.find, which where "." has the special meaning of "any character". This means, Utils.splitString(".",...) splits at any character.

Here you find an equivalent function to Utils.splitString.

Just add a "true" as the 4th parameter to all the string.find calls. I will add an optional parameter to Utils.splitString to change this behavior, but this will only be available in future games or addons of GIANTS Software.

Note: Log in to post. Create a new account here.