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.