I believe that’s the idea — hard to say what the original vision was back in 2009 that set this architecture, and how best practice for using Defold has evolved since then.
Off the top of my head there are two good reasons to not have direct communication (or read/write dependencies):
- You can’t control in which order different script’s
initandupdateare called, making it troublesome to have one component depend on output of another (during the same frame). - Code is executed in the context of the script or gui_script that got the original call, determining what e.g.
go.get_position()produces. This can get confusing If you have a lot of callbacks that are conceptually associated with one script/GO but called in another GO’s context.
Still, if you have a complex simulation with many update steps and data dependencies, it might get complicated to design that primarily with messages (I haven’t attempted it). Personally, I prefer having as much logic as I can in my own game loop and modules that I fully manage, and have scripts’ responsibility be to manage Defold engine objects.