Skip to content

Instantly share code, notes, and snippets.

@tomodachi94
Created December 9, 2022 19:16
Show Gist options
  • Save tomodachi94/ef2d00fa090dc593f7cdaa049db7dbe1 to your computer and use it in GitHub Desktop.
Save tomodachi94/ef2d00fa090dc593f7cdaa049db7dbe1 to your computer and use it in GitHub Desktop.
Startup.d: Portable startup directory

Startup.d

Usage

Place this file into the startup file: Leave off the extension, as it's more portable across legacy mod versions.

Place files you want to run into /startup.d You may place folders there as well, but they must have an init.lua inside of them.

-- Startup.d: Portable startup directories
local function startup(startup_dir)
local startup_dir = startup_dir or "/startup.d" -- use the specified folder if it provided, otherwise use default
for _, v in pairs(fs.list(startup_dir)) do
local file = fs.combine(startup_dir .. "/", v)
if fs.isDir(file) then -- Support directories with init.lua
dofile(fs.combine(file, "init.lua"))
else
loadfile(file)
end
end
end
startup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment