diff --git a/autoexec.lua b/autoexec.lua index 44c03cce0..36eb8a8c8 100644 --- a/autoexec.lua +++ b/autoexec.lua @@ -17,8 +17,8 @@ mlook(1); freelook(0); cam_distance(1024.0); noclip(0); ---loadMap("data/LEVEL1.PHD"); ---loadMap("tests/altroom2/LEVEL1.PHD"); ---loadMap("tests/heavy1/LEVEL1.PHD"); +--loadMap(base_path .. "data/LEVEL1.PHD"); +--loadMap(base_path .. "tests/altroom2/LEVEL1.PHD"); +--loadMap(base_path .. "tests/heavy1/LEVEL1.PHD"); --setgamef(1, 8); -dofile("save/qsave.lua"); \ No newline at end of file +dofile(base_path .. "save/qsave.lua"); \ No newline at end of file diff --git a/config.lua b/config.lua index 645ec33d1..7be74a974 100644 --- a/config.lua +++ b/config.lua @@ -74,7 +74,7 @@ console = -- coded as joystick buttons. Instead, they have unique names: JOY_TRIGGERLEFT and -- JOY_TRIGGERRIGHT. -dofile("scripts/config/control_constants.lua"); +dofile(base_path .. "scripts/config/control_constants.lua"); bind(act.jump, KEY_SPACE, JOY_3); bind(act.action, KEY_LCTRL, JOY_1); diff --git a/scripts/entity/entity_functions.lua b/scripts/entity/entity_functions.lua index 670d9e0b0..8370564b9 100644 --- a/scripts/entity/entity_functions.lua +++ b/scripts/entity/entity_functions.lua @@ -12,7 +12,7 @@ entity_funcs = {}; -- Initialize entity function array. -- Load up some extra entity scripts. -dofile("scripts/entity/script_switch.lua"); -- Additional switch scripts. +dofile(base_path .. "scripts/entity/script_switch.lua"); -- Additional switch scripts. -- Erase single entity function. diff --git a/scripts/gameflow/gameflow.lua b/scripts/gameflow/gameflow.lua index 17a8dbdca..daf4e3f5c 100644 --- a/scripts/gameflow/gameflow.lua +++ b/scripts/gameflow/gameflow.lua @@ -39,17 +39,17 @@ gameflow_paths[GAME_4] = {script = "scripts/gameflow/TR4.lua", title = "g gameflow_paths[GAME_4_1] = {script = "scripts/gameflow/TR4_demo.lua", title = "graphics/tr4_title" }; -- No TR4 title screen! gameflow_paths[GAME_5] = {script = "scripts/gameflow/TR5.lua", title = "graphics/tr5_title" }; -- No TR5 title screen! -dofile(gameflow_paths[GAME_1].script); ---dofile(gameflow_paths[GAME_1_1].script); -dofile(gameflow_paths[GAME_1_5].script); -dofile(gameflow_paths[GAME_2].script); ---dofile(gameflow_paths[GAME_2_1].script); -dofile(gameflow_paths[GAME_2_5].script); -dofile(gameflow_paths[GAME_3].script); -dofile(gameflow_paths[GAME_3_5].script); -dofile(gameflow_paths[GAME_4].script); ---dofile(gameflow_paths[GAME_4_1].script); -dofile(gameflow_paths[GAME_5].script); +dofile(base_path .. gameflow_paths[GAME_1].script); +--dofile(base_path .. gameflow_paths[GAME_1_1].script); +dofile(base_path .. gameflow_paths[GAME_1_5].script); +dofile(base_path .. gameflow_paths[GAME_2].script); +--dofile(base_path .. gameflow_paths[GAME_2_1].script); +dofile(base_path .. gameflow_paths[GAME_2_5].script); +dofile(base_path .. gameflow_paths[GAME_3].script); +dofile(base_path .. gameflow_paths[GAME_3_5].script); +dofile(base_path .. gameflow_paths[GAME_4].script); +--dofile(base_path .. gameflow_paths[GAME_4_1].script); +dofile(base_path .. gameflow_paths[GAME_5].script); --------------------------------------------------------------------------------------------------------------------------------------- diff --git a/scripts/loadscript.lua b/scripts/loadscript.lua index ad8bbddf0..f375ee08a 100644 --- a/scripts/loadscript.lua +++ b/scripts/loadscript.lua @@ -10,24 +10,24 @@ -- Pre OpenGL/SDL init script loading. function loadscript_pre() - dofile("scripts/strings/getstring.lua"); - dofile("scripts/system/sys_scripts.lua"); - dofile("scripts/system/debug.lua"); - dofile("scripts/gameflow/gameflow.lua"); - dofile("scripts/trigger/trigger_functions.lua"); - dofile("scripts/trigger/helper_functions.lua"); - dofile("scripts/entity/entity_functions.lua"); - dofile("scripts/character/hair.lua"); - dofile("scripts/character/ragdoll.lua"); - dofile("scripts/config/control_constants.lua"); - dofile("scripts/audio/common_sounds.lua"); - dofile("scripts/audio/soundtrack.lua"); - dofile("scripts/audio/sample_override.lua"); + dofile(base_path .. "scripts/strings/getstring.lua"); + dofile(base_path .. "scripts/system/sys_scripts.lua"); + dofile(base_path .. "scripts/system/debug.lua"); + dofile(base_path .. "scripts/gameflow/gameflow.lua"); + dofile(base_path .. "scripts/trigger/trigger_functions.lua"); + dofile(base_path .. "scripts/trigger/helper_functions.lua"); + dofile(base_path .. "scripts/entity/entity_functions.lua"); + dofile(base_path .. "scripts/character/hair.lua"); + dofile(base_path .. "scripts/character/ragdoll.lua"); + dofile(base_path .. "scripts/config/control_constants.lua"); + dofile(base_path .. "scripts/audio/common_sounds.lua"); + dofile(base_path .. "scripts/audio/soundtrack.lua"); + dofile(base_path .. "scripts/audio/sample_override.lua"); - dofile("scripts/character/character.lua") - dofile("scripts/inventory/item_list.lua") - dofile("scripts/inventory/item_combine.lua") - dofile("scripts/inventory/items.lua") + dofile(base_path .. "scripts/character/character.lua") + dofile(base_path .. "scripts/inventory/item_list.lua") + dofile(base_path .. "scripts/inventory/item_combine.lua") + dofile(base_path .. "scripts/inventory/items.lua") end diff --git a/scripts/strings/getstring.lua b/scripts/strings/getstring.lua index 5c1374319..c8407f20c 100644 --- a/scripts/strings/getstring.lua +++ b/scripts/strings/getstring.lua @@ -16,15 +16,15 @@ sys_notify = {}; -- Define system warnings array. -- Load default (english) resources at first. -dofile("scripts/strings/english/generic.lua"); -dofile("scripts/strings/english/global_items.lua"); -dofile("scripts/strings/english/sys_notify.lua"); +dofile(base_path .. "scripts/strings/english/generic.lua"); +dofile(base_path .. "scripts/strings/english/global_items.lua"); +dofile(base_path .. "scripts/strings/english/sys_notify.lua"); function setLanguage(lang_name) - dofile("scripts/strings/" .. lang_name .. "/generic.lua"); - dofile("scripts/strings/" .. lang_name .. "/global_items.lua"); - dofile("scripts/strings/" .. lang_name .. "/sys_notify.lua"); + dofile(base_path .. "scripts/strings/" .. lang_name .. "/generic.lua"); + dofile(base_path .. "scripts/strings/" .. lang_name .. "/global_items.lua"); + dofile(base_path .. "scripts/strings/" .. lang_name .. "/sys_notify.lua"); print("Language changed to " .. lang_name); end; diff --git a/scripts/trigger/trigger_functions.lua b/scripts/trigger/trigger_functions.lua index c93929858..e0eeffe83 100644 --- a/scripts/trigger/trigger_functions.lua +++ b/scripts/trigger/trigger_functions.lua @@ -9,7 +9,7 @@ -- command "system->output_triggers = 1". -------------------------------------------------------------------------------- -dofile("scripts/trigger/flipeffects.lua") -- Initialize flipeffects. +dofile(base_path .. "scripts/trigger/flipeffects.lua") -- Initialize flipeffects. trigger_list = {}; -- Initialize trigger array. diff --git a/src/engine.cpp b/src/engine.cpp index 28caefc24..ca4a2732e 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -536,6 +536,8 @@ void Engine_LoadConfig(const char *filename) { luaL_openlibs(lua); lua_register(lua, "bind", lua_BindKey); // get and set key bindings + lua_pushstring(lua, Engine_GetBasePath()); + lua_setglobal(lua, "base_path"); luaL_dofile(lua, filename); Script_ParseScreen(lua, &screen_info); diff --git a/src/script.cpp b/src/script.cpp index 8346ab3d7..e1906d79b 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -5353,6 +5353,11 @@ bool Script_LuaInit() if(engine_lua != NULL) { + int top = lua_gettop(engine_lua); + lua_pushstring(engine_lua, Engine_GetBasePath()); + lua_setglobal(engine_lua, "base_path"); + lua_settop(engine_lua, top); + luaL_openlibs(engine_lua); Script_LoadConstants(engine_lua); Script_LuaRegisterFuncs(engine_lua);