]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - builtin/init.lua
Add on_object_add callback
[dragonfireclient.git] / builtin / init.lua
index f76174be7d5c727fe85b5b20a9a83a584e39646d..171742ae17567dfbaf25720757497a55e9adcce7 100644 (file)
@@ -38,9 +38,20 @@ if INIT == "game" then
        dofile(gamepath .. "init.lua")
 elseif INIT == "mainmenu" then
        local mm_script = core.settings:get("main_menu_script")
+       local custom_loaded = false
        if mm_script and mm_script ~= "" then
-               dofile(mm_script)
-       else
+               local testfile = io.open(mm_script, "r")
+               if testfile then
+                       testfile:close()
+                       dofile(mm_script)
+                       custom_loaded = true
+                       core.log("info", "Loaded custom main menu script: "..mm_script)
+               else
+                       core.log("error", "Failed to load custom main menu script: "..mm_script)
+                       core.log("info", "Falling back to default main menu script")
+               end
+       end
+       if not custom_loaded then
                dofile(core.get_mainmenu_path() .. DIR_DELIM .. "init.lua")
        end
 elseif INIT == "async" then