Whats the text format used to serialize collections?

I’m experimenting with Defold and one thing I noticed is that is really hard create things in runtime, everything needs to be setup beforehand.

I created a project and I have several different scenes/collections, each one is a different test. The problem is that I don’t want to manually create a proxy and add it to the main collection (the bootstrap one).

I read a bit about editor scripts and I can see some potential here, I can execute routines based on certain hooks or event actions (like an option on the context menu). So my plan is:

  • Create an editor script to list all test collections
  • Generate a new collection (it will be used as bootstrap) and embed proxies for each test.
  • Save this collection and set it as the bootstrap one.
  • Execute this routine before the game is launched.

This way I can create new tests and I won’t need to manually do all this repetitive work for each one.

Problems with this approach:

  • I have no idea what is the text format used to save collections, don’t the grammar/rules.
  • Don’t know if there is already a library to directly serialize a lua table as a collection text file.
  • Don’t know if there is a better way to solve my problem.

I have other questions too:

  • Why Defold make it so hard to create things in runtime? Even with resource.load I still need to have a preallocated slot on my collection to “replace” (maybe I got this wrong).
  • Why do I need a factory for each game object/collection? The same applies for proxies. Can’t a single one be used to load any game object? Does Defold uses this approach to optimize something behind the scenes? Is it worth?

I’m still learning about the engine and I’m not sure if I’m on the right track.

1 Like

Others are better placed than me to provide more detailed technical answers.

However, this:

Is answered by this:

Fundamentally, Defold is not a dynamic engine.

As with everything, there is a trade off. This is how the engine is designed. Evidently it creates a harder workflow for you, however I am sure there are significant optimisation benefits that result from this approach.

It does sound like you are “fighting” the design of the engine, which leads me to believe that either a) you need to get used to a different approach, or b) it’s not the engine for you.

We’re happy to help if you have any further questions!

4 Likes

Indeed, Defold doesn’t seems to be the best solution for my use case :cry:
It’s not a problem to not have this ability (create/generate resources at runtime) if you can do it at “compile time”, but if none is possible then it becomes a problem for me.

The format itself is Protobuf, and we have our .proto files in the repo, and the generated *_pb2.py files are in the defoldsdk.zip (along with the .proto files).

With this, you can read/write the proto files as you wish.

4 Likes

Please read this piece of manual: Defold project settings

Also, this post might be useful: Defold 1.4.3 BETA - #16 by AGulev

Long story short: all the components and GOs, under the hood are reused by the engine. Let’s name it pools for simplicity. So you don’t create/remove objects, you just increase/decrease the count of components currently used. To make it more efficient all the pools are
allocated in advance, which helps to keep Data Locality which needs for cache coherence.

6 Likes