Hey, the love.thread thing really need a bit more description at the wiki. I like to input a variable in the thread and get a return after a function call. In this case I put 10 in, the function should add 3 and the return should be 13. But the function inside the thread doesn´t get called. and in generell I have no clue what is going on.
--thread.lua
local c1 = {...}[1]
function test(input)
a = 3
a = a + input
print(a)
return a
end
input = c1:demand()
c1:push(test(input))
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
-- main.lua
function love.load()
t = love.thread.newThread("thread.lua")
c1 = love.thread.newChannel()
input = 10
c1:push(input)
t:start(c1)
table = c1:demand()
print(table)
end
-- thread.lua
local c1 = ...
function test(input)
a = 3
a = a + input
print(a)
return a
end
input = c1:demand()
c1:push(test(input))
Of course you probably don't want to use threads for this, but it should work.
thread.lua
local c1 = ...
input = c1:demand()
print("thread/ input: "..input) -- print 10
function test(input)
a = input
a = a + 3
print("thread/ a: "..a) -- print 13
return a
end
c1:push(test(input))
So your issue is that the print command doesn't work in the thread? Because it seems like the thread did return 10 to the main thread, and it was printed...
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.