Store script directory in app context

This enables easier testing of the dev branch by providing a custom
script directory. Additionally, a Launch file is now searched for
in nearby locations and if found, used to determine a custom script
directory.
This commit is contained in:
meehl committed 2025-12-15 17:18:56 +01:00
1 parent e395e729e8
commit 031df6ed9c
9 files changed
+118 -79

No files matched your search

+6 -5
View File
@@ -2,18 +2,19 @@ use mlua::{IntoLuaMulti, Lua, MultiValue, Result as LuaResult, Value};
use std::{fs, path::PathBuf};
use crate::{
args::Game,
lua::Context,
util::{change_working_directory, get_executable_dir},
};
pub fn get_user_path(_: &Lua, _: ()) -> LuaResult<PathBuf> {
Ok(Game::user_data_dir())
pub fn get_user_path(l: &Lua, _: ()) -> LuaResult<PathBuf> {
let ctx = l.app_data_ref::<&'static Context>().unwrap();
Ok(ctx.script_dir().join("userdata"))
}
// parent directory of Launch.lua script
pub fn get_script_path(_: &Lua, _: ()) -> LuaResult<PathBuf> {
Ok(Game::script_dir())
pub fn get_script_path(l: &Lua, _: ()) -> LuaResult<PathBuf> {
let ctx = l.app_data_ref::<&'static Context>().unwrap();
Ok(ctx.script_dir().to_owned())
}
// parent directory of executable