Page 2 of 2

Re: Love Game Slave Example Source & Performance

Posted: Tue Jun 21, 2011 12:57 pm
by bartbes
Cylog wrote: musicload.lua:

Code: Select all

local this_thread = love.thread.getThread()
local msg = this_thread:receive("ping")
while (true) do
if (msg) then
this_thread:send("response", true)
end
end
It only checks for ping at startup, that loop will never update msg.
Also, it's a busy loop, I'd go for demand instead.

Re: Love Game Slave Example Source & Performance

Posted: Tue Jun 21, 2011 1:39 pm
by Cylog
bartbes wrote:... I'd go for demand instead.
Well, I tried demand...

in musicload.lua:

Code: Select all

local this_thread = love.thread.getThread()
local msg = this_thread:demand("ping")
while (true) do
if (msg) then
this_thread:send("response", true)
end
end
and also in routines.lua,

Code: Select all

function eventtimer(dt)
time = time + (timerspeed * dt)
--EVENT 1
if time >= 1500 then
layerdecayactive = true
end
--EVENT 2

if time >= 1400 then
--play music
--	love.audio.play(music4)
musicload:send("ping", true)
response = musicload:demand("response")
if (message) then 
love.graphics.setBackgroundColor(255,255,255)
end
--initiate sound management
soundcontrolactive = true
end
end 
...still didn't do anything. The Background Color remains (0,0,0)

Re: Love Game Slave Example Source & Performance

Posted: Tue Jun 21, 2011 1:59 pm
by bartbes

Code: Select all

local this_thread = love.thread.getThread()
while (true) do
local msg = this_thread:demand("ping")
if (msg) then
this_thread:send("response", true)
end
end
In the loop! Also, if your game doesn't hang using demand, it means the thread has either errored or replied, in your case I'd expect an error occurred. Try receiving the "error" variable for that.

Re: Love Game Slave Example Source & Performance

Posted: Tue Jun 21, 2011 2:19 pm
by Cylog
bartbes wrote:In the loop!
Yeah, I was expecting this. I tried it both ways, in the loop and out of the loop, and both didn't work. The game doesn't get stuck or changes the background-color.
Sorry for asking such a noobish question... but what do you mean by getting the "error" variable? Just:

Code: Select all

errormsg = musicload:demand("error")
?

Re: Love Game Slave Example Source & Performance

Posted: Tue Jun 21, 2011 3:04 pm
by bartbes
With receive, but yes.

Re: Love Game Slave Example Source & Performance

Posted: Tue Jun 21, 2011 3:28 pm
by Cylog
...it returns nil -.-
So, you mean to debug it like this? Displaying the error message?

Code: Select all

function eventtimer(dt)
time = time + (timerspeed * dt)
--EVENT 1
if time >= 1500 then
layerdecayactive = true
end
--EVENT 2

if time >= 1400 then
--play music
--	love.audio.play(music4)
musicload:send("ping", true)
response = musicload:demand("response")
errormsg = musicload:receive("error")
love.graphics.printf(errormsg, 10, 10,( maxx - 10), "left")
if (message) then 
love.graphics.setBackgroundColor(255,255,255)
end

end
end