Created
January 31, 2021 22:42
-
-
Save leiradel/a6816f251927e6216b0a619039ffa2d3 to your computer and use it in GitHub Desktop.
Auto-run Lua script for HC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local hc = require 'hc' | |
local lfs = require 'lfs' | |
local logger, config = hc.logger, hc.config | |
local coresPath = config:getCoresPath() | |
logger:info('Looking for Lua scripts in "%s"', coresPath) | |
for file in lfs.dir(coresPath) do | |
if file:sub(-4, -1) == '.lua' then | |
logger:info('Found "%s", running...', file) | |
local func, err = loadfile(coresPath .. file, 't') | |
if not func then | |
logger:error('%s', err) | |
else | |
local ok, err = pcall(func) | |
if not ok then | |
logger:error('%s', err) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment