Ninjadoodle Posted July 19, 2018 Share Posted July 19, 2018 Hi @enpu Sorry about all the questions today, I'm desperately trying to finish my game before the weekend. Is there a way I can set the Storage ID inside the main file, instead of the config? I'm trying this but it doesn't seem to work ... game.config.storage.id = 'gameR1'; Quote Link to comment Share on other sites More sharing options...
enpu Posted July 19, 2018 Share Posted July 19, 2018 Where exactly you have that line? Storage id needs to be set before the engine starts, so setting it for example inside scene won't work. Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 19, 2018 Author Share Posted July 19, 2018 @enpu This is where I'm trying to put it (I'm trying to use the system so I can have multiple episodes using the same src folder) game.module( 'game.mainR1' ) .require( 'game.menu', 'game.objects', // *********** // * ROUND 1 * // *********** 'game.stage01', 'game.stage02', 'game.stage03', 'game.stage04', 'game.stage05', 'game.stage06', 'game.stage07', 'game.stage08', 'game.stage09', 'game.stage10', 'game.stage11', 'game.stage12', 'game.stage13', 'game.stage14', 'game.stage15', 'game.stage16', 'game.stage17', 'game.stage18', 'game.stage19', 'game.stage20', // *********** // * PLUGINS * // *********** 'plugin.essentials', 'plugin.instantgames' ) .body(function() { // CONFIG game.config.name = 'Game - Round 1'; game.config.storage.id = 'gameR1'; game.createScene('MainR1', { init: function() { game.system.setScene('Menu'); } }); }); Quote Link to comment Share on other sites More sharing options...
enpu Posted July 19, 2018 Share Posted July 19, 2018 Looks good to me. So how does it not work? Do you get any error message? Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 19, 2018 Author Share Posted July 19, 2018 @enpu - Uncaught TypeError: Cannot set property 'id' of undefined (mainR1:40) Quote Link to comment Share on other sites More sharing options...
enpu Posted July 19, 2018 Share Posted July 19, 2018 Ah. You are trying to set property id to game.config.storage object, which you have not defined. game.config.storage = { id: 'gameR1' }; Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 19, 2018 Author Share Posted July 19, 2018 @enpu - Hmmm, I was trying not to define it in the config file, as that file will be used by 3 separate episodes, that's why I'm setting the name in the main file also. I assume, each episode will need a different storage id, in order to function, otherwise the progress might get overwritten. Quote Link to comment Share on other sites More sharing options...
enpu Posted July 19, 2018 Share Posted July 19, 2018 Well you can define just an empty storage object in your config file, then your game.config.storage.id = 'gameR1'; line should work. But my example should work also, really no big difference. Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 19, 2018 Author Share Posted July 19, 2018 @enpu - Oh ok, I didn't realize that you had to do that, and that it could be overridden like that, thank you for the tip!! Quote Link to comment Share on other sites More sharing options...
enpu Posted July 19, 2018 Share Posted July 19, 2018 Well you are not overriding anything there. That's just basic JavaScript, you can't set property into object that's undefined. game.config.storage.id = 'myid'; // Error because storage object is not definfed game.config.storage = {}; // Define storage object game.config.storage.id = 'myid'; // Set property id to storage object Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 19, 2018 Author Share Posted July 19, 2018 Hi @enpu - You underestimate how little I know lol Thank you heaps for explaining this, I really need to pick up a Javascript book that I can read in my spare time, it will help a lot. I'm getting ok at using Panda, but it's all just learning from examples and docs. Thanks again for giving me those tips! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.