Im New, And I Need Some Help.

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Neverfly
Prole
Posts: 10
Joined: Sat Jun 06, 2009 5:39 pm

Im New, And I Need Some Help.

Post by Neverfly »

Yo, Im new here [ In fact VERY new, I just downloaded LOVE 10 minutes ago ], and.. I need some help.
In the update function, is there a function to overload setBackgroundColor?

Heres the Code that I have:

Code: Select all

Cor = coroutine.create(function()
while true do
local a = math.random(1,255)
local b = math.random(1,255)
local c = math.random(1,255)
coroutine.yield(a,b,c)
end
end)



function load()
Text = love.graphics.newFont(love.default_font,12)
love.graphics.setFont(Text)
Message = "Neverfly"
love.graphics.setBackgroundColor(200,0,0)
x = 50
y = 100
a,b,c = 0,0,0
end


function update(dt)
love.graphics.setBackgroundColor(coroutine.resume(Cor, a, b,c)) -- ERROR HERE!
if love.keyboard.isDown(love.key_right) then
x = x + 5
elseif love.keyboard.isDown(love.key_left) then
x = x - 5
end
if love.keyboard.isDown(love.key_up) then
y = y -5
elseif love.keyboard.isDown(love.key_down) then
y = y + 5
end
end

function draw()
love.graphics.draw("Y Value is: ["..x.."]", 1, 15)
love.graphics.draw("X Value is: ["..y.."]", 1, 30)
   love.graphics.draw(Message, x, y)
   end
Think ya can help?
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Im New, And I Need Some Help.

Post by rude »

Welcome to LÖVE, dawg.

I've never used coroutines. That's right; never, so when I ask if the error message by any chance is "attempt to yield across C boundary", it is certainly a shot in the dark.
User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: Im New, And I Need Some Help.

Post by osgeld »

theres no real reason to even use a coroutine here, just stick it in a function and call it when you need a new random color

ive been scripting with lua in various forms since early 2007, and i personally have never found a real use for coroutines
User avatar
Star Crunch
Prole
Posts: 33
Joined: Sun Feb 15, 2009 12:13 am
Location: Monterrey, MX
Contact:

Re: Im New, And I Need Some Help.

Post by Star Crunch »

coroutine.resume() returns a boolean as the first argument, followed by your yield values. So you're doing something like love.graphics.setBackgroundColor(true, 38, 92).

If you don't need fine control, like checking the coroutine status and such, you may want to go with coroutine.wrap() instead.
Neverfly
Prole
Posts: 10
Joined: Sat Jun 06, 2009 5:39 pm

Re: Im New, And I Need Some Help.

Post by Neverfly »

MK, Thanks
mjau
Prole
Posts: 1
Joined: Thu Jun 25, 2009 9:07 pm

Re: Im New, And I Need Some Help.

Post by mjau »

Don't waaaanna keep this maaail.

...Cha.
Post Reply

Who is online

Users browsing this forum: No registered users and 51 guests