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.”

GitHub

1 Like

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.

4 Likes

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.

4 Likes

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!

8 Likes

I am using ecs in my games. I use tiny ecs
https://github.com/bakpakin/tiny-ecs with some modifications.

Ecs in game:https://github.com/d954mas/2.5d-shooter/tree/master/model/battle/ecs

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.

4 Likes

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.

2 Likes

Lovetoys?
:smirk:

7 Likes

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: https://github.com/critique-gaming/crit/blob/master/crit/context.lua

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:

8 Likes

@dapetcu21 I would love some day to read an in-depth blog about your usage of Defold in such way. :heart:

I am using dispatcher from crit repository - it’s a totally awesome system and if you ask me - it could be a default way of sending messages in Defold.

I “discovered” (read it: I managed to understand) recently context and just realized it’s a perfect tool for making logic in one script to manage many, many game objects, kind of like in ECS! Then I came across this post :wink:

3 Likes

Hi! So, we’re not really actively working on that project anymore, but yeah, the architecture was interesting, since the game had a lot of moving parts. It was a bit inspired by Flux, if you’re familiar with the JS world. I recommend watching this, even if it doesn’t 100% apply to games: Hacker Way: Rethinking Web App Development at Facebook - YouTube

Also, really glad someone is using Crit <3 Let me know if you have any questions! Oh, and I’d also be looking at progression.lua :wink: It’s a coroutine framework and probably one of the things that we used a lot in all our Defold games.

3 Likes