Page 1 of 1

Splitting Numbers Into A Table

Posted: Sat Apr 16, 2022 5:25 pm
by TheDirtMan
I want to put a number (or a string would be fine) and I want to separate each character and put it as its own value in a table. Help would be great thanks!

Re: Splitting Numbers Into A Table

Posted: Sat Apr 16, 2022 7:59 pm
by BrotSagtMist

Code: Select all

 s="artnsieniasoghccep9876k"
t={}
for x=1,#s do t[x]=sring.sub(s,x,x) end

Re: Splitting Numbers Into A Table

Posted: Sun Apr 17, 2022 6:10 pm
by darkfrei
TheDirtMan wrote: Sat Apr 16, 2022 5:25 pm I want to put a number (or a string would be fine) and I want to separate each character and put it as its own value in a table. Help would be great thanks!
Almost all questions are on the stackoverflow:
https://stackoverflow.com/questions/204 ... g-to-table

Re: Splitting Numbers Into A Table

Posted: Mon Apr 18, 2022 5:04 pm
by milon
Tip: When searching for help with Love, unless you're using a love.?? function, it's probably actually a question about Lua. That's been really helpful for me personally, as I didn't know Lua before migrating to Love.

Re: Splitting Numbers Into A Table

Posted: Mon Apr 18, 2022 10:25 pm
by TheDirtMan
Thanks to both of you, i will check stackoverflow from now on instead of posting here

Re: Splitting Numbers Into A Table

Posted: Tue Apr 19, 2022 2:13 pm
by BrotSagtMist
Nah, asking questions is what a forum is for.