Load modules correctly independent of working directory
John Smith

John Smith commited on 2022-23 11:08:22
Showing 2 changed files, with 8 additions and 6 deletions.

... ...
@@ -2,8 +2,10 @@
2 2
     deck loading and saving functions (working with Recfiles)
3 3
 ]]
4 4
 
5
-local Prompt = dofile "prompt.lua"
6
-local recrw = dofile "recrw.lua"
5
+local SRC_DIR = arg[0]:match("^.*/") or ""
6
+
7
+local Prompt = dofile(SRC_DIR .. "prompt.lua")
8
+local recrw = dofile(SRC_DIR .. "recrw.lua")
7 9
 
8 10
 --[[
9 11
     load a deck (a table of tables of `Prompt`s) from a Recfile
... ...
@@ -2,11 +2,11 @@
2 2
     the main user interface for memoire
3 3
 ]]
4 4
 
5
-local SRC_DIR = arg[0]:match("^.*/")
5
+local SRC_DIR = arg[0]:match("^.*/") or ""
6 6
 
7
-local Prompt = dofile "prompt.lua"
8
-local review = dofile "review.lua"
9
-local loader = dofile "loader.lua"
7
+local Prompt = dofile(SRC_DIR .. "prompt.lua")
8
+local review = dofile(SRC_DIR .. "review.lua")
9
+local loader = dofile(SRC_DIR .. "loader.lua")
10 10
 
11 11
 --[[
12 12
     gets the score (again/hard/good/easy/correction) from a string by first character
13 13