Is it possible to create multiple data/code files to store game data? #121
-
Putting and entire game into 2-3 files is a bit unwieldy. I'd prefer If I could separate out sections into their own files. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Me too! Just make sure you list all the files in settings.js in the right order. For example:
|
Beta Was this translation helpful? Give feedback.
-
It depends... If you are splitting up an existing file, put it in that order. First chunk in first file, second chunk in second file, etc. You cannot refer to anything in a later file from an earlier file. So "code" needs to go first if it has functions you use elsewhere. But if it refers to objects defined in other files, that has to go at the end. You may want to have a "functions" file first, and another later. That said, objects are usually referenced by string, and if you do that, you can references them before you create them. I hope that makes sense? |
Beta Was this translation helpful? Give feedback.
It depends...
If you are splitting up an existing file, put it in that order. First chunk in first file, second chunk in second file, etc.
You cannot refer to anything in a later file from an earlier file. So "code" needs to go first if it has functions you use elsewhere. But if it refers to objects defined in other files, that has to go at the end. You may want to have a "functions" file first, and another later. That said, objects are usually referenced by string, and if you do that, you can references them before you create them.
I hope that makes sense?