cooperuser / blockade

A minimal but challenging puzzle game, inspired by the ice puzzles in The Legend of Zelda: Twilight Princess.
2 stars 0 forks source link

Saving/loading levels with spaces or special characters #16

Open grady404 opened 8 years ago

grady404 commented 8 years ago

If I save a level that has spaces in its name (or apostrophes, and other characters I'm sure), the level does not load properly upon reopening, and causes the game to display a blank level and then freeze, forcing the game to be closed. Something to do with escape characters, shouldn't be a hard fix.

cooperuser commented 8 years ago

By hiding the .json from the names of the files in the open menu, I used files.replace('.')[0] which would make any levels that have a . in their name not work.

grady404 commented 8 years ago

Why don't you just do something like this (I know this is Python, but I'm sure there's a similar way to do it in JS):

if filename[-5:] == ".json": filename = filename[:-5]

That way even if the file name doesn't end in .json, the level can still be displayed and loaded normally.

Or actually, forget what I said above. If you wanted support for all file extensions, you could just find the last . in the file name, and then cut it off from there, but if you don't find a . don't do anything. That way if the file name is something like grady.level.json it will display it as grady.level.

cooperuser commented 8 years ago

Yeah, but there was also a glitch that happened where there is a blank level selectable, not sure what is causing it though

grady404 commented 8 years ago

What? Explain

cooperuser commented 8 years ago

ill try to re-create

grady404 commented 8 years ago

Add it to the issue tracker