start saving edits right in the source dir

[?]
Sep 9, 2023, 5:47 PM
2NQZJUPTOHIMDTSB2V53KQ5HLKKUUHQEKVB4XEHVFXOSI7UUGCJAC

Dependencies

  • [2] FD6GKGZE add a link
  • [3] 55UFMP6U slightly easier to understand
  • [4] TFRXO4PW simplify check for '0000'
  • [5] GACNGS44 combine 2 levels of indent
  • [6] 3LU2TYSW bugfix: deleting definitions
  • [7] LRDM35CE app running again
  • [8] FFFJ54GJ restore globals after running tests
  • [9] NMZSTB75 one more fix
  • [10] EZHO4TSW new file-system format for freewheeling apps
  • [11] 2DVVKKVA flesh out Readme
  • [12] 3BRGOF7N return failing tests with every code change
  • [13] WYKKFV2G prevent overriding foundational definitions
  • [14] IJQP7HJK bugfix: only include files with numeric _prefixes_
  • [15] D4FEFHQC flesh out Readme
  • [*] BSDXVB3H backport some doc updates and renames
  • [*] FS2ITYYH record a known issue

Change contents

  • edit in live.lua at line 19
    [17.549]
    [5.1470]
    -- We try to save new definitions in the source directory, but this is not
    -- possible if the app lives in a .love file. In that case new definitions
    -- go in the save dir.
  • edit in live.lua at line 51
    [5.2087][5.2087:2158](),[5.2158][5.586:857](),[5.857][5.9:103](),[5.103][5.950:1081](),[5.950][5.950:1081](),[5.1081][5.3845:3869](),[5.3845][5.3845:3869](),[5.3869][3.10:111]()
    print('new edits will go to ' .. love.filesystem.getSaveDirectory())
    -- if necessary, copy files from repo to save dir
    if io.open(love.filesystem.getSaveDirectory()..'/0000-freewheeling-start') == nil then
    print('copying all definitions from repo to save dir')
    for _,filename in ipairs(love.filesystem.getDirectoryItems('')) do
    local numeric_prefix, root = filename:match('^(%d+)-(.+)')
    if numeric_prefix then
    local buf = love.filesystem.read(filename)
    print('copying', filename)
    love.filesystem.write(filename, buf)
    end
    end
    end
    -- list files to load in save dir
    -- (ignore the repo because we might have deleted definitions)
  • replacement in live.lua at line 52
    [5.1181][5.9:145](),[5.145][4.11:77](),[4.77][5.85:261](),[5.85][5.85:261](),[5.261][5.4253:4263](),[5.427][5.4253:4263](),[5.1480][5.4253:4263](),[5.4253][5.4253:4263]()
    if io.open(love.filesystem.getSaveDirectory()..'/'..filename) then
    local numeric_prefix, root = filename:match('^(%d+)-(.+)')
    if numeric_prefix and not numeric_prefix:match('^0+$') then
    Live.filename[root] = filename
    table.insert(Live.filenames_to_load, filename)
    Live.final_prefix = math.max(Live.final_prefix, tonumber(numeric_prefix))
    end
    [5.1181]
    [5.4263]
    local numeric_prefix, root = filename:match('^(%d+)-(.+)')
    if numeric_prefix and tonumber(numeric_prefix) > 0 then -- skip 0000
    Live.filename[root] = filename
    table.insert(Live.filenames_to_load, filename)
    Live.final_prefix = math.max(Live.final_prefix, tonumber(numeric_prefix))
  • edit in live.lua at line 156
    [5.2177]
    [5.2177]
    -- try to remove the file from both source_dir and save_dir
    -- this won't work for files inside .love files
    App.remove(App.source_dir..Live.filename[definition_name])
  • replacement in live.lua at line 214
    [5.2716][5.2716:2757]()
    love.filesystem.write(filename, buf)
    [5.2716]
    [5.9]
    -- try to write to source dir
    local status, err = App.write_file(App.source_dir..filename, buf)
    if err then
    -- not possible; perhaps it's a .love file
    -- try to write to save dir
    local status, err2 = App.write_file(App.save_dir..filename, buf)
    if err2 then
    -- throw an error
    live.send_to_driver('ERROR '..tostring(err..'\n\n'..err2))
    return
    end
    end
  • replacement in README.md at line 30
    [5.2866][5.2866:2958](),[5.2958][2.18:160]()
    To publish your changes:
    * delete all files with a numeric prefix from the repo, and then
    * move all files with a numeric prefix from the [save directory](https://love2d.org/wiki/love.filesystem.getSaveDirectory)
    to the repo.
    [5.2866]
    [5.504]
    If you run a .love file, your changes will go into the [save directory](https://love2d.org/wiki/love.filesystem.getSaveDirectory).
    If you unzip the .love file into a new directory and run the directory
    instead, your changes will go straight into the same directory.