The binary versions of Defold data files have a ‘c’ appended to their extensions, for instance .goc for a compiled .go file, .spritec for a compiled .sprite and so on. The files are in binary protobuf format and created by the build tools. As you probably understand now you can’t use a .go file and rename it .goc since it will still be in the verbose protobuf text mode format which is not supported at runtime.
So let’s say you have two factories in your game, factoryA
and factoryB
, and they can spawn two different game objects, /game/enemyA.go
and /game/enemyB.go
. Now if you want factory A to spawn enemyB instead of enemyA, you can do like this:
factory.unload("#factoryA")
factory.set_prototype("#factoryA", "/game/enemyB.goc")
local enemy_of_type_b = factory.create("#factoryA")