Signals & Events Module [FREE CODE]

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: Signals & Events Module [FREE CODE]

Post by Kingdaro » Fri May 29, 2015 8:54 pm

SuperZazu wrote: Yes, but that would mean that you'd have a condition each frame of the game update... Not so pretty, mainly if you have a lot of objects to test.
How is it expensive in the slightest? Chances are, it's just

Code: Select all

function Player:isDead()
  return self.health <= 0
end
Or similar. And when do you not have a condition every frame? How does this post even make sense? You still have to somehow check if the player is dead somewhere every frame in order to fire the event anyway.

User avatar
SuperZazu
Citizen
Posts: 56
Joined: Sun Jun 10, 2012 2:06 pm
Location: France
Contact:

Re: Signals & Events Module [FREE CODE]

Post by SuperZazu » Fri May 29, 2015 9:13 pm

Kingdaro wrote:
SuperZazu wrote: Yes, but that would mean that you'd have a condition each frame of the game update... Not so pretty, mainly if you have a lot of objects to test.
How is it expensive in the slightest? Chances are, it's just

Code: Select all

function Player:isDead()
  return self.health <= 0
end
Or similar. And when do you not have a condition every frame? How does this post even make sense? You still have to somehow check if the player is dead somewhere every frame in order to fire the event anyway.
Well, you do. But the player class takes care of the player, and the game state is just a big container of objects.
If you start checking if the user is alive in the game state, you couple the classes with each other. With a signal, you can avoid that :-)

User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: Signals & Events Module [FREE CODE]

Post by Kingdaro » Sat May 30, 2015 2:27 am

I'm not gonna say anything for decoupling or against it, but for god's sake, don't blindly follow it if it makes things more complicated and more difficult for your code to weave through and understand.

But I'm not even saying signals aren't useless, just having a signal object that could only have one connection. How we got to this tangent is beyond me.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 5 guests