@@ -1092,6 +1092,7 @@ bool Core::InitMainThread(std::filesystem::path path) {
10921092 std::cerr << " Build url: " << Version::dfhack_run_url () << std::endl;
10931093 }
10941094 std::cerr << " Starting with working directory: " << Filesystem::getcwd () << std::endl;
1095+ std::cerr << " Hack path: " << getHackPath () << std::endl;
10951096
10961097 std::cerr << " Binding to SDL.\n " ;
10971098 if (!DFSDL::init (con)) {
@@ -1233,9 +1234,9 @@ bool Core::InitSimulationThread()
12331234{
12341235 // the update hook is only called from the simulation thread, so capture this thread id
12351236 df_simulation_thread = std::this_thread::get_id ();
1236- if (started)
1237+ if (started)
12371238 return true ;
1238- if (errorstate)
1239+ if (errorstate)
12391240 return false ;
12401241
12411242 // Lock the CoreSuspendMutex until the thread exits or call Core::Shutdown
@@ -1277,20 +1278,20 @@ bool Core::InitSimulationThread()
12771278 std::cout << " Console disabled.\n " ;
12781279 }
12791280 }
1280- else if (con.init (false ))
1281+ else if (con.init (false ))
12811282 std::cerr << " Console is running.\n " ;
12821283 else
12831284 std::cerr << " Console has failed to initialize!\n " ;
1284- /*
1285- // dump offsets to a file
1286- std::ofstream dump("offsets.log");
1287- if(!dump.fail())
1288- {
1289- //dump << vinfo->PrintOffsets();
1290- dump.close();
1291- }
1292- */
1293- // initialize data defs
1285+ /*
1286+ // dump offsets to a file
1287+ std::ofstream dump("offsets.log");
1288+ if(!dump.fail())
1289+ {
1290+ //dump << vinfo->PrintOffsets();
1291+ dump.close();
1292+ }
1293+ */
1294+ // initialize data defs
12941295 virtual_identity::Init (this );
12951296
12961297 // create config directory if it doesn't already exist
@@ -1307,7 +1308,8 @@ bool Core::InitSimulationThread()
13071308 else
13081309 {
13091310 // ensure all config file directories exist before we start copying files
1310- for (auto &entry : default_config_files) {
1311+ for (auto & entry : default_config_files)
1312+ {
13111313 // skip over files
13121314 if (!entry.second )
13131315 continue ;
@@ -1317,19 +1319,22 @@ bool Core::InitSimulationThread()
13171319 }
13181320
13191321 // copy files from the default tree that don't already exist in the config tree
1320- for (auto &entry : default_config_files) {
1322+ for (auto & entry : default_config_files)
1323+ {
13211324 // skip over directories
13221325 if (entry.second )
13231326 continue ;
13241327 std::filesystem::path filename = entry.first ;
1325- if (!config_files.contains (filename)) {
1328+ if (!config_files.contains (filename))
1329+ {
13261330 std::filesystem::path src_file = getConfigDefaultsPath () / filename;
13271331 if (!Filesystem::isfile (src_file))
13281332 continue ;
13291333 std::filesystem::path dest_file = getConfigPath () / filename;
13301334 std::ifstream src (src_file, std::ios::binary);
13311335 std::ofstream dest (dest_file, std::ios::binary);
1332- if (!src.good () || !dest.good ()) {
1336+ if (!src.good () || !dest.good ())
1337+ {
13331338 con.printerr (" Copy failed: '{}'\n " , filename);
13341339 continue ;
13351340 }
@@ -1340,6 +1345,17 @@ bool Core::InitSimulationThread()
13401345 }
13411346 }
13421347
1348+ // set lua default path if not already set
1349+ if (std::getenv (" DFHACK_LUA_PATH" ) == nullptr )
1350+ {
1351+ std::filesystem::path lua_path = getHackPath () / " lua" / " ?.lua" ;
1352+ #ifdef WIN32
1353+ _putenv_s (" DFHACK_LUA_PATH" , lua_path.string ().c_str ());
1354+ #else
1355+ setenv (" DFHACK_LUA_PATH" , lua_path.string ().c_str (), 1 );
1356+ #endif
1357+ }
1358+
13431359 loadScriptPaths (con);
13441360
13451361 // initialize common lua context
0 commit comments