look for init.d directories in the root instead of raw/

develop
Myk Taylor 2023-01-15 23:28:01 -08:00
parent 50cc6d965d
commit 762cd46d14
No known key found for this signature in database
4 changed files with 15 additions and 15 deletions

@ -216,10 +216,10 @@ after a modded save is unloaded.
.. _other_init_files: .. _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. will be run when any world or that save is loaded.

@ -5883,9 +5883,9 @@ all script modules.
Save init script 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. 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: such script can define the following functions to be called by dfhack:
* ``function onStateChange(op) ... end`` * ``function onStateChange(op) ... end``

@ -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/`` ``example-mod`` mod will be developed in the ``/path/to/mymods/example-mod/``
directory and has a basic structure that looks like this:: directory and has a basic structure that looks like this::
raw/init.d/example-mod.lua init.d/example-mod.lua
raw/objects/... raw/objects/...
raw/scripts/example-mod.lua raw/scripts/example-mod.lua
raw/scripts/example-mod/... 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. 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. mod when a save is loaded.
* Modifications to the game raws (potentially with custom raw tokens) go in * Modifications to the game raws (potentially with custom raw tokens) go in
``raw/objects/``. ``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. 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. scripts and/or modules used by your mod.
It is a good idea to use a version control system to organize changes to your 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 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``:: 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 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 -- main setup and teardown for example-mod
-- this next line indicates that the script supports the "enable" -- 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 You can call ``enable example-mod`` and ``disable example-mod`` yourself while
developing, but for end users you can start your mod automatically from 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') dfhack.run_command('enable example-mod')

@ -905,14 +905,14 @@ if dfhack.is_core_context then
local path = dfhack.getSavePath() local path = dfhack.getSavePath()
if path and op == SC_WORLD_LOADED then 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 if dirlist then
table.sort(dirlist) table.sort(dirlist)
for i,name in ipairs(dirlist) do for i,name in ipairs(dirlist) do
if string.match(name,'%.lua$') then if string.match(name,'%.lua$') then
loadInitFile(path, path..'/raw/init.d/'..name) loadInitFile(path, path..'/init.d/'..name)
end end
end end
end end