tobiasvl / lasertank-pico8

:video_game::checkered_flag: LaserTank port for PICO-8
https://tobiasvl.itch.io/lasertank-pico8
MIT License
2 stars 1 forks source link

Tool for converting LVL files to strings #10

Open tobiasvl opened 6 years ago

tobiasvl commented 6 years ago

This issue is not related to anything else, and does not require any knowledge of PICO-8, Lua, or LaserTank for that matter. This is simple IO and parsing of a binary file.

I'm thinking a simple command line tool (Python?) that takes a .LVL file as input, and outputs a text file with the level data as strings.

.LVL files are just a series of levels, one after another, where each level has the following format:

The easiest would just be to dump that as follows, one after another in a text file:

levels={
  {
    "Tile data goes here, as hex characters in a simple string, for example 000100020f04 etc.",
    "Title goes here",
    "Hint goes here",
    "Author goes here",
    -- Difficulty goes here in something that's not a string possibly, just a decimal number is fine
  },
  -- more levels go here
}

Then I can just copy and paste the contents of that file into the .P8 file and we're ready to go.

tobiasvl commented 6 years ago

Since PICO-8 has a small resolution and no built-in capabilities for formatting strings:

It would be nice if the level hints could be split into several lines (ie. just insert \n in the string), where each line is no longer than 32 characters long. However, the string should be split on word boundaries (otherwise I could just do it in the display code).

If no word boundaries are fine, just insert -\n instead (counting the dash as one of those 32 characters). We don't need to get too fancy.