So Im trying to make my blocks change color in real time but for some reason the code I'm using won't work.

There's a lot of confusing things going on in this code. I've been using LUA for a while but I really don't know if what you're doing will work how you expect. If you're trying to go for a object oriented code style I would recommend using one of the class libraries from the Love2D forums. I don't have LOVE on this computer so I can't compile your code, so I can't tell what's happening.

That aside I can recommend you try a few things.

self.image_color =
self.image ='fill', 1, 20, 20, 20) does not have a return value. Neither does As such this code right here is either doing absolutely nothing (I don't have love2d on my machine here to check), setting self.image_color to be a reference to that function, or calling the function and then inserting nil into self.image_color.

if x.color == YELLOW then
x.color = RED

Secondly, you can't compare tables like this in LUA. Unless the two tables reference the same object, == can't be used to compare them. Now in this case, it might work because x.color was explicitly set to RED or YELLOW, right? But the thing is that I don't know if using local self makes lua consider it another instance of the table, and breaks your comparator. It would help if you could tell what happens when you compile your code.

Thirdly, for the most obvious answer.

function love.draw()
    x.color = YELLOW

If you explicitly set the color of your object to yellow right before you draw it, it's going to draw as yellow.

/r/love2d Thread