Storing object data between scenes

Hi,

I’m totally new to defold & lua, but seems amazing so far, im currently going through the RPG tutorial which stores each screen in a collection factory along with all the enemies / items etc within that screen.

But if I was to kill an enemy / destroy, once I leave the screen and come back its reset again I assume because the whole scene is being removed and then created again when I switch.

Is there a tutorial anybody knows off on how to solve this? I have browsed about and seen people mention tables and other things but I have no idea what that is, are there any good tutorials on it?

Also if it helps most the enemies / items I want to remember the state of already exist in the scene and are not created on the fly using ‘factory.create’

Thanks

You can use Modules to keep track of your enemies, state or whatever you want.
Modules documentation is here: Lua modules in Defold
Tables are kind of a bag :slight_smile: You can put everything in it. (ex: Modules are tables)

3 Likes

oh that looks perfect i will have a read through it all thanks a lot :slight_smile:

1 Like