Hello,
I have string variable that holds a load of text, and I am trying to split it.
The string is basically player names, and player scores, it is displayed like this:
“player-score player-score player-score” → “oliver-10 alex-20 tom-45”
And I want to break it out into arrays.
This is what I have so far (Start Function):
var playerEntries : String[];
var playerData : String[];
var playerNamePull : String;
var playerScorePull : int;
playerEntries = formText.Split("
"[0]);
for(var entry : String in playerEntries){
playerData = entry.Split("-"[0]);
playerNamePull = playerData[0];
playerScorePull = System.Convert.ToInt32(playerData[1]);
}
Now, the playerEntries array works fine:
oliver-10
alex-20
tom-45
But nothing in the ‘for’ works - what am I doing wrong?
I’m trying to get it like this:
playerNamePull (string array) :
oliver
alex
tom
playerScorePull (int array) :
10
20
45
Thanks