From 762cd46d14be7738464c430ec4919092882654e4 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 15 Jan 2023 23:28:01 -0800 Subject: [PATCH] look for init.d directories in the root instead of raw/ --- docs/Core.rst | 6 +++--- docs/dev/Lua API.rst | 4 ++-- docs/guides/modding-guide.rst | 14 +++++++------- library/lua/dfhack.lua | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/Core.rst b/docs/Core.rst index 28e20a827..86e357b27 100644 --- a/docs/Core.rst +++ b/docs/Core.rst @@ -216,10 +216,10 @@ after a modded save is unloaded. .. _other_init_files: -raw/init.d/\*.lua -................. +init.d/\*.lua +............. -Any lua script named ``raw/init.d/*.lua``, in the save or main DF directory, +Any lua script named ``init.d/*.lua``, in the save or main DF directory, will be run when any world or that save is loaded. diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 39bd57046..813406013 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -5883,9 +5883,9 @@ all script modules. Save init script ================ -If a save directory contains a file called ``raw/init.lua``, it is +If a save directory contains a file called ``init.lua``, it is automatically loaded and executed every time the save is loaded. -The same applies to any files called ``raw/init.d/*.lua``. Every +The same applies to any files called ``init.d/*.lua``. Every such script can define the following functions to be called by dfhack: * ``function onStateChange(op) ... end`` diff --git a/docs/guides/modding-guide.rst b/docs/guides/modding-guide.rst index ab52e0288..224448cf1 100644 --- a/docs/guides/modding-guide.rst +++ b/docs/guides/modding-guide.rst @@ -358,7 +358,7 @@ names for the mod folders within it. In the example below, we'll use a mod ID of ``example-mod`` mod will be developed in the ``/path/to/mymods/example-mod/`` directory and has a basic structure that looks like this:: - raw/init.d/example-mod.lua + init.d/example-mod.lua raw/objects/... raw/scripts/example-mod.lua raw/scripts/example-mod/... @@ -366,13 +366,13 @@ directory and has a basic structure that looks like this:: Let's go through that line by line. -* A short (one-line) script in ``raw/init.d/`` to initialise your +* A short (one-line) script in ``init.d/`` to initialise your mod when a save is loaded. * Modifications to the game raws (potentially with custom raw tokens) go in ``raw/objects/``. -* A control script in ``raw/scripts/`` that handles enabling and disabling your +* A control script in ``scripts/`` that handles enabling and disabling your mod. -* A subfolder for your mod under ``raw/scripts/`` will contain all the internal +* A subfolder for your mod under ``scripts/`` will contain all the internal scripts and/or modules used by your mod. It is a good idea to use a version control system to organize changes to your @@ -384,10 +384,10 @@ Unless you want to install your ``raw/`` folder into your DF game folder every time you make a change to your scripts, you should add your development scripts directory to your script paths in ``dfhack-config/script-paths.txt``:: - +/path/to/mymods/example-mod/raw/scripts/ + +/path/to/mymods/example-mod/scripts/ Ok, you're all set up! Now, let's take a look at an example -``raw/scripts/example-mod.lua`` file:: +``scripts/example-mod.lua`` file:: -- main setup and teardown for example-mod -- this next line indicates that the script supports the "enable" @@ -474,7 +474,7 @@ Ok, you're all set up! Now, let's take a look at an example You can call ``enable example-mod`` and ``disable example-mod`` yourself while developing, but for end users you can start your mod automatically from -``raw/init.d/example-mod.lua``:: +``init.d/example-mod.lua``:: dfhack.run_command('enable example-mod') diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua index a4d233a9e..e2cb7069b 100644 --- a/library/lua/dfhack.lua +++ b/library/lua/dfhack.lua @@ -905,14 +905,14 @@ if dfhack.is_core_context then local path = dfhack.getSavePath() if path and op == SC_WORLD_LOADED then - loadInitFile(path, path..'/raw/init.lua') + loadInitFile(path, path..'/init.lua') - local dirlist = dfhack.internal.getDir(path..'/raw/init.d/') + local dirlist = dfhack.internal.getDir(path..'/init.d/') if dirlist then table.sort(dirlist) for i,name in ipairs(dirlist) do if string.match(name,'%.lua$') then - loadInitFile(path, path..'/raw/init.d/'..name) + loadInitFile(path, path..'/init.d/'..name) end end end