Game Editor Split string

Non-platform specific questions.

Game Editor Split string

Postby tzoli » Wed Nov 16, 2011 8:39 pm

Hi.
How can I split a string to array by a special character.(like explode() in PHP).
Exemple:
"6,6,6,6,6,6,
4,4,4,4,4,4,
4,4,4,4,4,4,
4,4,4,4,4,4,
4,4,4,4,4,4,
4,4,4,4,4,4,
4,4,4,4,4,4,
4,4,4,4,4,4,
4,4,4,4,4,4,
4,4,4,4,4,4"
to split with "," and get an array(ex. words) words[0] supposed to be 6 but words [6] supposed to be 4
Is there a solution?
Creepers are capable of climbing ladders, despite lacking arms. (Minecraft wiki)
User avatar
tzoli
 
Posts: 343
Joined: Sat Jun 12, 2010 6:54 pm
Location: Behind you
Score: 15 Give a positive score

Re: Game Editor Split string

Postby skydereign » Wed Nov 16, 2011 10:50 pm

From what you've posted, it sounds like you just want to remove the commas from the string. If you did that, then words[6] would be 4, while words[0] would be 6. Of course, unlike explode, you aren't dealing with an array of strings. So, you could manually break up the string into an array of strings or you can grab substrings from a normal string (using something like strncpy(text, &word[6], 6);).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Game Editor Split string

Postby tzoli » Tue Nov 22, 2011 7:11 pm

Thanks
Creepers are capable of climbing ladders, despite lacking arms. (Minecraft wiki)
User avatar
tzoli
 
Posts: 343
Joined: Sat Jun 12, 2010 6:54 pm
Location: Behind you
Score: 15 Give a positive score

Re: Game Editor Split string

Postby tintran » Fri Dec 02, 2011 8:55 pm

2 functions in Global code called chrCount and explode
usage in Script: exploded -> Create Actor
I am curious in what you're trying to build with these functions.
Attachments
explode.zip
(18.96 KiB) Downloaded 87 times
explode.png
User avatar
tintran
 
Posts: 157
Joined: Fri Dec 24, 2010 1:34 am
Score: 30 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest