[Plugin]Base32k (un)pack (localstorage spacesaver)

0 favourites
  • 13 posts
From the Asset Store
Unlock platyers earning coins, and save it with Localstorage
  • Update : use version 1.1, which allows minification ! :

    https://dl.dropbox.com/u/1412774/Base32kDemo/pode_base32k.1.1.zip

    Here's a plugin to deal with the problem of unsufficient space storage (localStorage or WebDB/variants).

    <img src="https://dl.dropbox.com/u/1412774/Base32kDemo/demo.png" border="0">

    When you use a lot of base64 strings (when switching images, for examples), saving them, sending them over the network, you have an overhead (since binary => base64 conversion can add up to 33% space used by the data).

    Saving them on disk is also a problem after some time.

    If you have a game (say, a visual novel) that uses a lot of text (XML or plain text, by the way), you also need to save a lot of text strings.

    This plugin use a nice property of Javascript strings. In fact, all Javascript Strings uses UTF-16 internally (or UCS-2, if you want to be more precise, depending on what side of psychorigidity you are). That means that two bytes are use internally to represent one character (so two bytes used to represent one byte => one byte is lost each time).

    Since non-latin alphabet are displayed with Unicode (UTF-16), you can do the same conversion that base64 does, but instead of going from binary data to latin alphabet, you go from binary data to asiatic characters !

    (That means you don't lose a byte every two bytes internally).

    So instead of loosing 33% more space in the worst case, you only loose around 3 or 4 percents...

    It's usefull when you want to save a string ondisk. PAck it with this Base32k plugin. When you want to use it back, load it, unpack it with this plugin, and *hop* it's done !

    The demo : https://dl.dropbox.com/u/1412774/Base32kDemo/index.html

    The plugin : https://dl.dropbox.com/u/1412774/Base32kDemo/pode_base32k.1.0.zip

    The .capx : https://dl.dropbox.com/u/1412774/Base32kDemo/Base32kDemo.capx

    This plugin is made with the help of this codebase : https://github.com/simonratner/base32k

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The demo doesn't seem to work in FF 15. Clicking the "Base32k" button doesn't display any new string. A "de-base 32k" appears, but bot text areas remain empty. (same notice in Chrome 21)

    Otherwise good idea and nice first explaining post !

  • Kyatric : argh ! As always, I forgot about minification ! It's workign without it. So, I'll grab a sandwich, take a lunck break, and post an update <img src="smileys/smiley2.gif" border="0" align="middle" />.

  • 1 this will be usefull if i want save my explored levels in my game?

    2 this will be work on android and ios?

  • delgado :

    1. if you save your levels in localStorage/Webstorage, yes.

    2. This should work everywhere, since it's entirely done in javascript.

  • Kyatric, All : first post updated, new release which handles minification nicely.

  • Now it's working.

    Good job Pode.

  • Good one! it may be useful to save space storage for complex games.

  • Looks beautiful! This should work nicely. Thank You!!

    By saving 50K text into Disk cache device,

    Firefox cache size increased from 38K to 63K. I think its quite good! Should be enough for save games.

  • Just curious, is there a character that is safe to use as a token if I were to use this in conjunction with tokenAt(,)?

  • newt : I didn't try. Logically, all the character are safe, even if they can't be displayed by the browser. However, you need to use a character that isn't in the Asian plane of Unicode/UTF8/UCS2/and all that... I think you are on the safe side if you choose a punctuation characte (like ';' or '-'). I can't test it right now, so tell me !

  • Ok wasn't sure what was included in usc-2 little endian, or not included in the plug.

    Google didn't yield much as far as that goes, and I didn't think testing using the standard characters would be a good idea, as they all would work until they didn't.

  • Please ReUpload it

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