]> git.jsancho.org Git - dungeon-master.git/commitdiff
Allow mods structured like modules
authorJavier Sancho <jsf@jsancho.org>
Wed, 10 Jun 2020 06:46:48 +0000 (08:46 +0200)
committerJavier Sancho <jsf@jsancho.org>
Wed, 10 Jun 2020 06:46:48 +0000 (08:46 +0200)
src/mods.cpp

index abdf472bfd8ff25c4c1a6519f1761a11773f94b7..dea09b633b0e40261e5d25c060b849e95bc3339b 100644 (file)
@@ -43,6 +43,13 @@ void scm_init_dungeon_master_module ()
   scm_c_define_module ("dungeon-master", init_dungeon_master_module, NULL);
 }
 
+void add_to_load_path (std::string path)
+{
+  // Add path to %load-path variable, needed for modules created in mods
+  std::string exp = "(add-to-load-path \"" + path + "\")";
+  scm_c_eval_string (exp.c_str ());
+}
+
 void load_dmaster_mods ()
 {
   scm_init_guile ();
@@ -58,6 +65,7 @@ void load_dmaster_mods ()
   for (const std::string &path : paths)
     {
       mods_path = path + PATH_DELIM + "mods";
+      add_to_load_path (mods_path);
       mods_dir = opendir (mods_path.c_str ());
       if (mods_dir != NULL)
         {