Love Game Slave Example Source & Performance

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Love Game Slave Example Source & Performance

Post 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.
Cylog
Prole
Posts: 12
Joined: Wed May 04, 2011 5:28 pm

Re: Love Game Slave Example Source & Performance

Post 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)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Love Game Slave Example Source & Performance

Post 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.
Cylog
Prole
Posts: 12
Joined: Wed May 04, 2011 5:28 pm

Re: Love Game Slave Example Source & Performance

Post 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")
?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Love Game Slave Example Source & Performance

Post by bartbes »

With receive, but yes.
Cylog
Prole
Posts: 12
Joined: Wed May 04, 2011 5:28 pm

Re: Love Game Slave Example Source & Performance

Post 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 
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests