[Plugin] instance bank2

  • johnnyl7x

    Pode has a FileSaver plugin which could save string into file.

  • Saw it before..

    Only save txt (Not stats), & can't load

    Need a simple save/load feature that save to file.

    Thx. <img src="smileys/smiley19.gif" border="0" align="middle" />

  • johnnyl7x

    You might try FileSaver + FileReader.

    BTW, the "expression: BankToString" will get a string, so user only need to save this string.

  • rexrainbow@

    You might try FileSaver + FileReader.

    BTW, the "expression: BankToString" will get a string, so user only need to save this string.

    Working example Capx-

    Download

    Capx also has a DRAG AND DROP option..so Podes Drag and drop plugin needed-

    LINK

    Working in Chrome browser.

    Test in browser here-

    TEST

  • This instance bank plugin is just a beginning. I plan to make another plugin to auto-save/load instance outside a range.

    Wow that sounds fantastic.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello everyone,

    This plugin seems to be very useful. However, I can't seem to figure out how to load back my sprites' instances from Webstorage. I'm certain that it is me (I am learning...slowly). :)

    Would it be possible to have an example on both how to save and then how to retrieve the sprites instances from Webstorage?

    ex:

    On Touch "save icon" ---) X,

                         ---) y.

                         ---) Z.

    On Touch "Load icon" ---) X.

                         ---) Y.

                         ---) Z.

    p.s.: I have read all post and view all referenced capx (it just doesn't seem to "sink in").

    Thank you very much!

  • Sobieski74

    Save bank to webstorage / load bank from webstorage

    User could get string by "expression: BankToString", then save this string into

    • global variable
    • dictionary
    • webstorage
  • Hello Rexrainbow,

    Would you, or anyone else, be so kind as to review my capx example?

    dropbox.com/s/f2s0jegexwnucqt/%21C2.capx

    My events to save and load to/from Webstorage are as followed:

    • KB: On S released --) IB: Clean bank to empty

                        --) IB: Save "chess" from all instances

    • IB: on saving "chess ---) IB: set local key "SAVE" to instancebank.banktostring
    • KB: On L released: WS: Set local storage from JSON string "SAVE"

                         IB: loadbank from JSON string to Webstorage.AsJSON

    • IB on loading "chess" ---) IB load all saved instances

    (KB = KEYBOARD, IB = INSTANCEBANK, WS = WEBSTORAGE)

    Should my command to save and load be any different than what I have inserted in order to work?

    Thank you very much! :)

  • Sobieski74

    <img src="http://i1081.photobucket.com/albums/j352/rexrainbow1/screen1-31_zpsa6a04144.png" border="0" />

    Call "action:set local key "SAVE" to instancebank.banktostring" after "action:Save "chess" from all instances"

  • Hello Rexrainbow,

    Thank you for the advice on how to save, I am now able to save and load back the instances (but only if I destroy the instances before attempting to load them back).

    dropbox.com/s/lywcvzegm9r6owu/Test2.capx

    (note that I made one extra change with the webstorage, by changing "set" to "merge" so that saved instances could be overwritten).

    I am only beginning with C2, but your plugins are of a great help!

    ps: I can't wait to be able to post the capx and images within the message! :)

    Thank you!

  • Sobieski74

    Using chess bank to save/load chess on the board.

  • r124 will support save/load system, cool!

  • The action of loading (official feature in r124) is interesting.

    Engine will create instance which UID is the same as saved.

    If the saved instance has existed when loading, it will be changed by loading info.

    So that the UID of these instance will not be changed after loading.

  • Yes, actually i use Instance Bank for memory managment, Save/Load system uses IndexDB which is not 100% supported to some platforms.

  • Great work! I think there is a bug with the picked by saved UID.

    After load all instances, picking by saved UID causes a duplication.

    The javascript code I think is wrong is

    InstBankKlassProto.LoadAllInstancesEpilogue = function()
    {
            this._z_sorting.Sorting();
            hash_clean(this._saveduid2inst_map);
    }; 
    

    The map of UIDs->saved instances is wiped after loading. I don't think this is the correct behaviour for using the pick by saved UID functionality after a load all instances.

    Anyway, to fix I just commented out the hash_clean line. Works for my program although obviously I might not understand the intended full semantics of the plugin.

    PS the duplication occurs because invalid pick params to pick by saved ID lazily creates an instance if none exists. I wonder if this is a bit dangerous, better to alert an error?

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