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

Post your completed addons to share with the community

Post » Thu Aug 30, 2012 11:15 am

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).

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/base32kPode2012-08-30 16:27:12
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Thu Aug 30, 2012 11:40 am

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 !Kyatric2012-08-30 11:41:55
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,786

Post » Thu Aug 30, 2012 12:11 pm

@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 .
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Thu Aug 30, 2012 1:26 pm

1 this will be usefull if i want save my explored levels in my game?
2 this will be work on android and ios?
B
93
S
19
G
34
Posts: 1,840
Reputation: 27,958

Post » Thu Aug 30, 2012 3:16 pm

@delgado :
1. if you save your levels in localStorage/Webstorage, yes.
2. This should work everywhere, since it's entirely done in javascript.
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Thu Aug 30, 2012 4:27 pm

@Kyatric, @all : first post updated, new release which handles minification nicely.
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Thu Aug 30, 2012 6:06 pm

Now it's working.
Good job Pode.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,786

Post » Thu Aug 30, 2012 8:44 pm

Good one! it may be useful to save space storage for complex games.Joannesalfa2012-08-30 20:54:56
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sat Sep 29, 2012 7:40 pm

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.mercy2012-09-29 20:06:34
B
25
S
5
G
5
Posts: 138
Reputation: 5,638

Post » Sat Dec 22, 2012 3:31 am

Just curious, is there a character that is safe to use as a token if I were to use this in conjunction with tokenAt(,)?
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest