Skip to content

Commit

Permalink
added base path using in scripts calling;
Browse files Browse the repository at this point in the history
  • Loading branch information
TeslaRus committed Oct 10, 2016
1 parent 82adcad commit 91113fe
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 41 deletions.
8 changes: 4 additions & 4 deletions autoexec.lua
Expand Up @@ -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");
dofile(base_path .. "save/qsave.lua");
2 changes: 1 addition & 1 deletion config.lua
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion scripts/entity/entity_functions.lua
Expand Up @@ -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.

Expand Down
22 changes: 11 additions & 11 deletions scripts/gameflow/gameflow.lua
Expand Up @@ -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);


---------------------------------------------------------------------------------------------------------------------------------------
Expand Down
34 changes: 17 additions & 17 deletions scripts/loadscript.lua
Expand Up @@ -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


Expand Down
12 changes: 6 additions & 6 deletions scripts/strings/getstring.lua
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion scripts/trigger/trigger_functions.lua
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions src/engine.cpp
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/script.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 91113fe

Please sign in to comment.