Lovetoys work in Defold? (ECS)


Lovetoys works with Defold? I would like to develop a game in Defold focused on ECS, but I would like to know if anyone has experience.
Still, I’m skeptical about the gain in “performance”, I try to develop a multiplayer game, and I have enough time to learn haha, maybe Defold works well as it is, with the help of the assets it has, but I don’t lose anything by asking ^^
“lovetoys is an Entity Component System framework for game development with lua.”




Yes probably. The GitHub page claims it work in any Lua based engine.

Yes, using an ECS system will very likely not give you any gain in performance. On the contrary.

Defold is built using something similar to ECS under the hood. A Defold game object maps to an Entity. And game objects have Components. Updated by Systems in the engine. The difference is that you can’t create you’re own Components and Systems. But slapping a Lua based ECS on top of Defold is probably not a very good solution, although I believe some users do it. I hope someone with experience with this can provide some feedback.



Since you mention “performance”, I suggest that you try to setup an example in Defold that actually tests your “worst case” scenario, to see if the performance meets your standards.



Thanks for the quick reply. I wanted to know if it was really worth focusing on ECS, but I think it will not be necessary, until now Defold has become my favorite game engine ^^, I have been using Unity for a while, I spent a while using Amethyst to achieve better performance, but I I really liked how Defold worked, in my opinion I feel that I have more control and better performance than in Unity, and I feel that it is easier to work with Defold, regarding amethyst.
The incredible thing is the performance and the light weight of the applications! It is incredible !, in unity my projects come to weigh much more when generating an executable file.
I really congratulate the development team!



I am using ecs in my games. I use tiny ecs with some modifications.

Ecs in game:

I don’t think that it give a performance, because performance boost get from data locality, which is not possible in lua.

But ecs is a good pattern, and I love it.

The main problem for me for using ecs, was that defold use messages system. And for example it is not comfortable to use ecs with physics or changing entity info in gui.

So it is possible to make ecs in defold, if you write some wrappers on top of engine.



This would be an interesting experiment to make. It’s probably possible to create something that fits with the Defold way of structuring things and perhaps leveraging message passing etc.






In our current project, we’re doing a lot of pub-sub across different scripts and the way we got around message passing was with this helper module:

Actually, for architecture, we have:

  • A common data model (with no logic apart from data structure accessors). You can subscribe to change notifications on most of the values from this model. This also needs to be serialisable for save/load.
  • A bunch of separate systems which implement different parts of the game’s logic. These modules can install hooks at different moments during the game’s core gameplay loop.
  • The presentation layer (Defold), where scripts just subscribe to the data model change notifications and whenever they need to perform mutations, they call into the logic systems through an action dispatcher (the actions themselves are also serialisable, for multiplayer).

The first two parts are pure Lua, with no Defold specifics, so that they can be easy to test and easy to transplant into a Lua server later on when we do multiplayer.

It’s not really ECS. I don’t really know how to describe it. It’s probably more akin to MVC, except the Controllers don’t interact with the view at all. Anyway, it works for me and keeps the mess contained :slight_smile: