Hot reload a collection loaded with a collection factory

I load a level collection with a collection factory. Hot reloading this collection produces this error:

ERROR:RESOURCE: /screens/gameworld/level/maps/map18.collectionc could not be reloaded since it was never loaded before.

The collection has been loaded and is visible on the screen when this log message appears. What kind of resources can be hot reloaded?

1 Like

Collections should be able to hot reload.
Not sure what goes in this case :thinking:

I believe all resources can be hot reloaded nowadays.

Can you share a minimal repro case and steps to reproduce? Preferably on GitHub!

There are some hoops to jump through to hot reload a lua module though, right?

1 Like

Yes, that is true. I don’t exactly recall what you need to do though (and yes, I should know!). I think you need to require the module again and you may also need to clear the _G.packages.loaded[“modulename”] entry.

There’s a workaround here. I’ve successfully used it in the past.

1 Like

I created an empty project with one line of code:

local game_object_ids = collectionfactory.create("#collectionfactory")

It produces the error in the first post when hot reloading. My guess is it doesn’t work because Defold loads the collection under the hood when create() is called?

Minimal project just in case: HotReloadCollection.zip (2.5 KB)

Note: Created GH issue https://github.com/defold/defold/issues/5527

1 Like