pass in files on the commandline

This commit is contained in:
Kartik K. Agaram 2023-04-20 19:27:06 -07:00
parent 674b04af40
commit 7a6f93bdf6
3 changed files with 13 additions and 5 deletions

View File

@ -1,6 +1,11 @@
on.initialize = function()
if love.filesystem.getInfo('graph') then
Nodes = json.decode(love.filesystem.read('graph'))
on.initialize = function(arg)
if #arg > 0 then
Filename = arg[1]
end
if file_exists(Filename) then
local f = App.open_for_reading(Filename)
Nodes = json.decode(f:read('*a'))
f:close()
end
A()
end
end

View File

@ -1,7 +1,9 @@
on.update = function(dt)
if Global_next_save and Global_next_save < Current_time then
print('saving')
love.filesystem.write('graph', json.encode(Nodes))
local f = App.open_for_writing(Filename)
f:write(json.encode(Nodes))
f:close()
Global_next_save = nil
end
if Pan then

1
0060-Filename Normal file
View File

@ -0,0 +1 @@
Filename = love.filesystem.getSourceBaseDirectory()..'/graph'