Multiple threads from one file?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Multiple threads from one file?
Here's the thread code, to save a back and forth of questions.
- Attachments
-
- genimage.lua
- CODE!
- (1.29 KiB) Downloaded 112 times
Re: Multiple threads from one file?
Code: Select all
s = s..k.."="..v..","
Code: Select all
local t = {2,4,6,72,34,5,6,43,6,63,32}
local s = table.concat(t, ",") --> "2,4,6,72,34,5,6,43,6,63,32"
Shallow indentations.
Re: Multiple threads from one file?
Wait, what?
I think you think I know what your talking about.
What is that first piece of code?
And how would I "un-concat" the string?
I think you think I know what your talking about.
What is that first piece of code?
And how would I "un-concat" the string?
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Multiple threads from one file?
Code: Select all
local t = {}
for v in str:gmatch("[^,]+") do table.insert(t, v) end
Code: Select all
local t = {}
local function insert(v) table.insert(t, v) end
str:gsub("[^,]+", insert)
Re: Multiple threads from one file?
The code is from TSerial.lua.
You can use the output of table.concat to create a string that is loadable with loadstring.
It still wastes memory and could be optimized to.
Lookup loadstring if you want to know what exactly it does.
(Code is untested)
You can use the output of table.concat to create a string that is loadable with loadstring.
Code: Select all
local original = {2,4,6,72,34,5,6,43,6,63,32}
local str = "return {".. table.concat(t, ",") .."}"
local copy = loadstring(str)()
Code: Select all
local original = {"return { [0]=nil", 2,4,6,72,34,5,6,43,6,63,32, "}"} -- Assuming we don't use the index 0.
local str = table.concat(t, ",")
local copy = loadstring(str)()
(Code is untested)
Shallow indentations.
Who is online
Users browsing this forum: Google [Bot] and 9 guests