[Plugin] instance bank2

0 favourites
From the Asset Store
The I18N (Translation) is a Construct plugin created to translate text in game.
  • Document, plugin and sample capx are included.

    Save/Load instances. It will save/load instances through part of official save/load system.

    Compare with official save/load system

    Official save/load system will save/load all instances. This plugin only save/load the specifics instances by type, unsaved instances will not be affected.

    plugin: Grid freezer

    Load saved instances part by part.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To think that 3 weeks ago i build my app using this principle with lots of events.

    And to find this plugin doing the same thing with mega speed and just a few events.

    Your rock!

    Now i just have to replace my events with your plugin.

    The result will be worth it!

    So thank u rexrainbow <img src="smileys/smiley32.gif" border="0" align="middle" />

    Im going to use this massivley.

    Kind Regards.

    Savvy001

  • Hi rexrainbow

    Thanks for this new plugin, but I am having an error message when unziping it.

  • NRABrazil

    Humm... it's my fail. You could rename *.txt to *.7z, then unzip it. I will try to fix this problem (all my zip files become *.txt) when I have time.

  • Hi, i used your plugin for the saving of my sprites into webstorage and load it when i reopen the game.

    It runs perfectly on preview mode, but when i try to run it after being exported, i get this error.

    Uncaught TypeError: Cannot call method 'getCurrentSol' of undefined c2runtime.js:11294

    InstBankKlassProto.CreateInstance c2runtime.js:11294

    InstBankKlassProto._load_all_instances_handler c2runtime.js:11324

    InstBankKlassProto.LoadAllInstances c2runtime.js:11330

    Acts.LoadInstances c2runtime.js:11055

    Action.run_object c2runtime.js:5968

    EventBlock.run_actions_and_subevents c2runtime.js:5570

    EventBlock.run c2runtime.js:5548

    EventSheet.run c2runtime.js:5208

    EventInclude.run c2runtime.js:6270

    EventSheet.run c2runtime.js:5208

    Runtime.logic c2runtime.js:2892

    Runtime.tick c2runtime.js:2750

    extra

    I have tried clearing cache, re-exporting in various options. Nothing works.

    ----------------------------------------------------------------------------------

    This is what i did, i created some instances of the sprites(Bricks) and (Connector). Then, i saved all the instances of the 2 sprite into the Instance Bank. Once saved, i use BankToString to store everything into WebStorage.

    When I open the browser again, i used

    Load Bank from JSON string WebStorage.LocalValue("InitialBricks")

    Once all that is done, I used

    Load all saved instances

    -----------------------------------------------------------------------------------

    I used this in preview mode, it works.

    But after i exported it, it gave me an error and stop working. Please help. Thanks

  • DaveSX

    I'm not sure. Test ok when I save instance bank into WebStorage, then load it immediately.

    You might provide a very simple test capx.

  • here is the link to the sample capx.

    It works fine in preview mode, but once exported it gave the error.

    docs.google.com/file/d/0B7VK2vJr4XSKNXJxN2lTdlZlUTQ/edit

  • DaveSX

    It seems you saved instance bank to JSON string (at default.json) at previous mode. Then use this saved data at exported mode.

    The C2 engine will rename all types, so that instance bank could not get the saved data by type name.

    You could create the default.json after exported to use the same type name.

  • Ahh... Got it to work. Thanks a lot.

  • Hi Rex!

    I have been doing a bit of digging into the demos you posted for InstanceBank. After adding in some debug output to print out the UID's for Main and Sub on "instbank_savedUID" as well as adding in a "onanykey" event to reload at will, I found that the original instances are not getting destroyed leading to duplication of the objects. This can be see most clearly with "instbank_savedUID" with the changes since it has movement and the new object show up looking like a fan blade.

    Here is a link to the modified capx file:

    https://www.dropbox.com/s/9pzrhs54u9v1mjn/instbank_savedUID-modified.capx

    (let me know if you can't get to it.)

    Thank you for making these plugins! It's so nice to see a community giving back to one another.

  • Ok, I did some more digging through related posts and it looks like this is by design. Destroy flags the sprite to be destroyed at the end of the event sheet per Ashley:

    This is sort of by design... "Destroy" means "flag to be destroyed at the end of the event sheet". This is because people commonly write events like

    Destroy Sprite

    Create explosion at Sprite.X, Sprite.Y

    If the Sprite was really destroyed, the explosion would have nowhere to be created because the Sprite doesn't have an X or Y co-ordinate any more. I could fix the two cases you've shown, but the object would still actually exist until the end of the event sheet, which might just make for some more confusing cases.

    So I guess this means if one is loading an InstanceBank, the layout should not have any pre created objects of the saved type in it prior to the loadAllInstances call, otherwise, duplication occurs.

    There I go, answering my own questions... lol

    Thanks!

  • Dieck

    Yes, you could call load many times , to create a lot of copies.

  • rexrainbow

    So in order to avoid the duplication, would it make sense to stage the load one event cycle after destroying the objects?

    Thanks!

  • Dieck

    It depends on your design.

  • rexrainbow

    Ok so given the example InstanceBank_savedUID, it seems no matter what I do to the original object sub and main, when LoadAllInstances get called, the newly load instances have new UIDs and the original instances always stay around. That would seem to indicate if you are loading objects from InstanceBank that were placed in the Layout editor, it will always duplicate on load with new UIDs. Is that the case?

    Would it be more appropriate to use a Dictionary or CSV object to store the individual object state including UID and then reset the sprites from that structure?

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