Yes, it should improve performance a bit, I am using it next way:
local msgs = require "modules.msgs"
...
msg.post("player#controller", msgs.HEALTH_DECREASE, { by: -1 })
...
Also it possible to register your go’s in some module with paths and do not use “player#controller”, something like:
local paths = require "modules.paths"
function init(self)
paths.register("player")
end
function final(self)
paths.remove("player")
end
and path.lua:
local M = {}
...
function M.register(name)
M[name] = msg.url()
end
function M.remove(name)
M[name] = nil
end
...
return M
And now we can use :
local msgs = require "modules.msgs"
local paths = require "modules.paths" --we can use one module here
...
if paths.player then --now we can check "if player exist"
msg.post(paths.player, msgs.HEALTH_DECREASE, { by: -1 })
end
...
Of course it is just a dirty example and of course, it’s possible to do better.
But what I wanna say, When I stared with Defold I hate Lua (I have exp. with AS3, C#, Haxe, Typescript before), but after some time I found it powerful and convenient for game development.
It is possible to avoid most of your concerns just using code architecture decisions. But it needs time to found them.
But… I like how Haxe help to avoid the same problems out of the box - it’s a really powerful language and Dan did a great job. If you like Haxe and don’t wanna spend your time to learn Lua, Haxe is a great solution for you, I think.
Also, it’s possible to use TypeScript, maybe it would be interesting for you.