Stringlist help

Post Reply
icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Stringlist help

Post by icesteruk »

Hey I have a list setup like

combat = {"hello", "goodbye", "good morning", "that isn't going ot happen"}

so if I do a 'for' to make it send it, it'll be like

for k, v in pairs(combat) do
send(v)
end

but it'll send them one at once, Does anyone know a way to send them all at once so it'll be like

hellogoodbyegood morningthat isn't going ot happen ...

When I use echo(v) it shows them all together like I want but when using send, it sends them one at once, I guess thats because the echo doesn't line separate like send does.. any ideas please?

hogarius
Posts: 35
Joined: Mon Nov 21, 2011 8:35 pm

Re: Stringlist help

Post by hogarius »

(Untested)

Code: Select all

combat = {"hello", "goodbye", "good morning", "that isn't going ot happen"}
text = ""

for k, v in ipairs(combat) do
  text = text .. v
end

send(text)
If you want to put a space between each element of combat, you can do something like the following (again, untested):

Code: Select all

combat = {"hello", "goodbye", "good morning", "that isn't going ot happen"}
text = ""

for k, v in ipairs(combat) do
  text = text .. v
  if  k < #combat then
    text = text .. " "
  end
end

send(text)

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Stringlist help

Post by Akaya »

Code: [show] | [select all] lua
table.concat(combat, "")

icesteruk
Posts: 287
Joined: Sun Jan 20, 2013 9:16 pm

Re: Stringlist help

Post by icesteruk »

Akaya wrote:
Code: [show] | [select all] lua
table.concat(combat, "")
That was first thing I tried, it wouldn't work in a send thing :(

Thanks tho the first stuff helped :)

Post Reply