[Plugin] instance bank2

  • Clean bank does not clear saved instance map which can cause some weird bugs down the line. I suggest changing JS "CleanBank" to:-

    InstBankKlassProto.CleanBank = function()
         {
            hash_clean(this._bank); 
            hash_clean(this._saveduid2inst_map); //NEW LINE
         }; 
    
  • Just learned today how insanely useful this is for level editors, especially when combined with the canvas plugin. Thanks man!!!

  • Found another bug that the saved instance map doesn't get wiped after a loadBankFromJSON.

    Its a fairly simple fix.

    I people want the bug fixes I would consider putting it on github

  • tlarkworthy

    There is an official save/load feature, I though this instance bank might not be necessary anymore.

  • tlarkworthy

    There is an official save/load feature, I though this instance bank might not be necessary anymore.

    rexrainbow I don't believe, it's hard to manage the selected instances, save and load does for everything including positions, it's annoying.

    I made a suggestion thread

    http://www.scirra.com/forum/suggestiOn-save-to-Object_topic78790.html

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There was an official expression: AsJson and action: Load from Json feature, so please do not use saveloadstatus plugin.

  • Thanks rexrainbow,

    I think that plugin will work for me.

    Note to future people: InstanceBank's JSON data won't work between exported websites and the development versions due to

    scirra.com/forum/help-me-fix-instancebank-across-exports_topic78823.html

  • HALLELUJAH!!!!!

    4 and a half hours later I have it working!

    The only holdup with SaveLoadStatus is that is does not like transferring data between layouts. The internal SDK loadInstanceFromJSON check the layer, and kills the instance if it can't find the correct layer to put the instance in. This is unfortunately is always the case when you load instance data from a different layout than you use the data :s

    Anyway I altered rexrainbow's SetStatus to overwrite the JSON data when loading, so the instance will be recreated *except* the layer info.

        Acts.prototype.SetStatus = function (obj_type, status)
         {     
            if (!obj_type)
                return; 
            status =  JSON.parse(status); 
              console.log("loading...", status);
             //if (obj_type.sid != status["sid"]) //removed, protection against instanciating in different layers
            var insts = obj_type.getCurrentSol().getObjects();
            var i, cnt=insts.length;
            for (i=0; i<cnt; i++){
                   status["w"]["l"] = insts[i].layer.sid //force loaded object into layer of containing instance
                this._set_status(insts[i], status);   
              }
         };   
    

    (It looked like in the code you knew this Rex but it did not work for my use case.)

  • wow thank you so much

  • Since I could reuse the official save/load feature in saveloadstatus plugin, it might be better to rewrite instancebank with reusing official save/load to support more save-able obejct types, include behaviors.

    But I do not have time now, sorry. <img src="smileys/smiley19.gif" border="0" align="middle" />

  • I think there is enough material for any motivated individual to build a new plugin version. You have done plenty :p

  • Since I could reuse the official save/load feature in saveloadstatus plugin, it might be better to rewrite instancebank with reusing official save/load to support more save-able obejct types, include behaviors.

    But I do not have time now, sorry. <img src="smileys/smiley19.gif" border="0" align="middle" />

    rexrainbow I would pay you $$ if you have time to make it.

  • rexrainbow

    Whenever I try your instbank2 basic.capx, I get this error when I press the spacebar:

  • Thanks, I will try to find time to fix it.

  • I just made an account to say that this plugin is freaking awesome. But you need to add one thing, you need to add a function where you can select what gets saved. For example; when I don't want to save the size or the position of an object, but I do want to save the instance variables.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)