From 53c35241fb1fbc01412e8e7899f14b3929472162 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 1 Jul 2022 13:55:43 -0700 Subject: [PATCH] ugh, handle absolute as well as relative paths --- Manual_tests.md | 8 ++++++++ main.lua | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Manual_tests.md b/Manual_tests.md index 8e9a02c..690ccd9 100644 --- a/Manual_tests.md +++ b/Manual_tests.md @@ -23,3 +23,11 @@ Lua is dynamically typed. Tests can't patch over lack of type-checking. * Like any high-level language, it's easy to accidentally alias two non-scalar variables. I wish there was a way to require copy when assigning. + +### Todo list + +* Initializing settings: + - from previous session + - Filename as absolute path + - Filename as relative path + - from defaults diff --git a/main.lua b/main.lua index 1ba8e6d..17a19e5 100644 --- a/main.lua +++ b/main.lua @@ -318,11 +318,15 @@ function love.quit() end -- save some important settings local x,y,displayindex = love.window.getPosition() + local filename = Filename + if filename:sub(1,1) ~= '/' then + filename = love.filesystem.getWorkingDirectory()..'/'..filename -- '/' should work even on Windows + end local settings = { x=x, y=y, displayindex=displayindex, width=App.screen.width, height=App.screen.height, font_height=Font_height, - filename=love.filesystem.getWorkingDirectory()..'/'..Filename, -- '/' should work even on Windows + filename=filename, screen_top=Screen_top1, cursor=Cursor1} love.filesystem.write('config', json.encode(settings)) end