Page 1 of 1

Multiple output streams in a for loop

PostPosted: Sat Jul 08, 2017 10:23 am
by Cactus
I have a for loop
It creates a output stream based on each value

I want it to be able to create individual separate output streams for each value
Currently as it iterates over the values in the for loop, it only leaves the most recent one with 1 output stream. Anything before that is not remembered

For example:
Code: Select all
For x in y do:
o = output_stream(x)

When I have 100 of x in y table, I am obviously left with only one o, where I wanted 100 o's (o1,o2,o3,etc.)

Can somebody show example lua code on how to accomplish this
Sorry if this is silly

Re: Multiple output streams in a for loop

PostPosted: Mon Jul 10, 2017 8:22 am
by Cactus
Ok I have now managed to solve this using global table like so

Code: Select all
for i = 1,tonumber(linecount) do   
    _G['outs'..i] = instance:addStream(tostring(i), core.Line, name, (tostring(i).."_e"), --color_extended, first)
end

for i = 1,counter do   
    r = _G['outs'..i]
end


then I use "r" in a loop, so everytime it is outs1, outs2, outs3 and so on