TIC-80 icon indicating copy to clipboard operation
TIC-80 copied to clipboard

Cartridges opened from the command line should be saved to their original location

Open moonlit opened this issue 6 years ago • 0 comments

TIC-80 supports opening cartridges directly from the command line, which is wonderful, but produces inconsistent results depending on where TIC-80 is called from relative to the cartridge.

execution directory: where TIC-80 is called from, and what it uses for loading most external files (injected sprites, specified .tic, Lua dofile(), etc) CLI working directory: exposed to the user via the internal interface

If TIC-80's execution directory is the same directory as the initial .tic cartridge file, then both the execution directory and the CLI working directory are set to that of the specified .tic file. In this case saves will operate correctly and update the original .tic file. This is the expected behaviour.

If TIC-80 is called from a different directory (by using relative directories to reach the initial .tic file), TIC-80 will set its CLI working directory to its default working directory instead, and saves will be made there. In this case the original .tic file is not updated, and rerunning the same command to launch TIC-80 will load the original unchanged .tic instead.

Maintaining the execution directory is important (so files specified on the command line and from within the .tic are loaded correctly). But when a .tic file is specified on the command line, TIC-80 has a few options that make sense.

  1. Retain the execution directory and set the CLI working directory to the same, while also maintaining the relative path to the specified .tic file
  2. Retain the execution directory and set the CLI working directory to that of the specified .tic file
  3. After injecting external files (code, sprites, etc), set both the execution directory and the CLI working directory to that of the specified .tic file

Option 1 ensures only that saving of the .tic file opened from the command line is saved. It does not make it clear where new cartridges or any other files will be saved, and does not make clear that files referenced from within TIC-80 (such as when using dofile()) must be specified relative to the directory TIC-80 was executed from. It also leaves open the question of where saves should go if the CLI working directory is changed via cd from within TIC-80.

Option 2 answers many of the questions presented by the first option but still leaves the door open for confusion (especially with users who are new to programming or using the command line) why the directories are not the same. This is much like TIC-80's current behaviour, but with the added benefit of working saves of loaded cartridges and new files being in the expected place in the filesystem.

Option 3 is what we would consider the best, but with the tradeoff that it will break any projects in progress that are loading external files from within TIC-80. As that is a relatively advanced feature, the change is probably worth it for the benefits it would bring to new users and to create a consistent experience both within the TIC-80 environment and when using external tools.

moonlit avatar Nov 11 '18 08:11 moonlit