how can I insert a single letter in a string?
like “abc” + d = “abcd”
how can I insert a single letter in a string?
like “abc” + d = “abcd”
local abc = "abc"
local d = "d"
print(abc.. d)
id like to add more like somehow insert it inside a string without using …
Concatenation is the simplest way to add letters into a string, what do you mean by “add more”?
like if I have a string of letters such as “123456789”
id like to keep adding more over time
You can use the ..=
operator for that I believe
local text = "abc"
text ..= "d"
print(text) --prints abcd
Future additions will be appended to the end of the string, @GoteeSign’s method is the same as how I did it
local abc = “abc”
abc = abc..'d'
Like the whole alphabet to be added over time?
that works but that’s only used once.
id like to be able to keep adding more and more
like if i’m inserting something in a table
If you want to add something else, just use it again
local text = "abc"
text..= "d"
--Later on
text ..= "e"
print(text) --Prints abcde
What are you trying to do?
local alphabet = 'abcdefghijklmnopqrstuvwxyz'
local h
local on = 1
while true do
h = string.sub(alphabet, 1, on)
on += 1
print(h)
if on == 26 then break end
wait(1)
end
im too lazy to indent
string = “”
for i,v in pairs(alphabet)
insert(v,string)
end
So you want to slowly add in the alphabet to a text? then just do this
local alphabet = 'abcdefghijklmnopqrstuvwxyz'
local text = ""
for i = 1, #alphabet do
text = alphabet:sub(1, i)
print(text)
wait(1)
end
so the alphabet is tons of numbers inside a table
and id like to add more as time goes on
Wait can you do #string instead of using string.len?
Your thing is still vague, try saying what you want step by step, the best I understood was the code I did
@GoteeSign And yes, # works for strings as well
I just realized that i can simply just do
String = String..tostring(v)
would that work?
If v
is somethign that can be turned into a string, yes. But it’s simpler to do
String ..= tostring(v)
Kinda depends on how you are using it in your script