Splitting Numbers Into A Table

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
TheDirtMan
Prole
Posts: 2
Joined: Sat Apr 16, 2022 5:22 pm

Splitting Numbers Into A Table

Post 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!
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: Splitting Numbers Into A Table

Post by BrotSagtMist »

Code: Select all

 s="artnsieniasoghccep9876k"
t={}
for x=1,#s do t[x]=sring.sub(s,x,x) end
obey
User avatar
darkfrei
Party member
Posts: 1197
Joined: Sat Feb 08, 2020 11:09 pm

Re: Splitting Numbers Into A Table

Post 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
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: Splitting Numbers Into A Table

Post 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.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
TheDirtMan
Prole
Posts: 2
Joined: Sat Apr 16, 2022 5:22 pm

Re: Splitting Numbers Into A Table

Post by TheDirtMan »

Thanks to both of you, i will check stackoverflow from now on instead of posting here
User avatar
BrotSagtMist
Party member
Posts: 657
Joined: Fri Aug 06, 2021 10:30 pm

Re: Splitting Numbers Into A Table

Post by BrotSagtMist »

Nah, asking questions is what a forum is for.
obey
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests