Blightmud / Blightmud

A terminal mud client written in Rust
GNU General Public License v3.0
218 stars 58 forks source link

Optional event handlers for file changes. #440

Closed lhandf closed 3 years ago

lhandf commented 3 years ago

It may be useful to have the option to have blightmud watch certain directories for changes, and attach a callback to that event. For example, it could be used for automatic reload:

scriptpath = "~/mud/"

blight.on_notify(scriptpath, function (path)
    if path:match("lusternia") then
        script.reset()
        script.load(scriptpath .. "lusternia/init.lua")
    elseif path:match("aetolia") then
        script.reset()
        script.load(scriptpath .. "aetolia/init.lua")
    end
end)

From a quick search, it could possibly use notify.

LiquidityC commented 3 years ago

I will test this out with the suggested lib. Concerns are performance and stability. But if it seems to work nice on Linux I think it's a really nice addition.