Saving and Sharing levels in an html5 app

Hi! I was wanting to build an html5 game with a level editor, and wanted players to be able to share levels with each other. Except I’ve hit several snags.

  1. Attempted to use local storage. Browser doesn’t seem to store the information in a place users can actually get to it, at least not in any way that players could share with other people.

  2. Create a sort of “seed” players can put into a text box to cause the game to load the level. Problem, while I can simulate proper textboxes using gui elements, I cannot find a way to allow players to copy/paste. Not in Defold or even in Lua itself.

  3. Decide, well, it’s html5…maybe I can interact with the webpage itself to use an html textbox. Except the generated javascript is fairly incomprehensible, which rules out editing it directly, and I can’t find a way to interact with the outside webpage otherwise. Webviews looked promising for being able to evaluate javascript, but attempting to use them gives an error (attempting to access a null global variable) and google seems to indicate that they’re maybe for mobile only, even though the api page doesn’t say anything about that.

Any ideas? I’m fairly stumped. Unfortunately, storing things server side just isn’t an option right now. What am I missing? Is something like this even possible?

We will open up for native extensions in HTML5 soon (mid-May) and this will solve many problems. Some thoughts:

  1. The local storage is not readily available to the user in any reasonable way I’m afraid.
  2. Copy/paste should be doable with native extensions on HTML5
  3. Interacting with the enclosing web page will be made possible using native extensions. Web views are only available on mobile.

Maybe sys.open_url() could work and perhaps the following URL to trigger an e-mail client:

mailto:?subject=Level seed&body=My cool seed is 123456

Hmm, ok, thanks. Certainly looking forward to the addition of the native extensions then. :slight_smile:

Have you considered using any baas or writing your own backend. Sounds like it would be a perfect match for such a thing storing away this data on a server instead of on the client itself.

1 Like

The idea was tossed around, but server based level storage is completely beyond our scope at the moment, and opens up some cans of worms I just don’t want to deal with.