Dead simple Garry's Mod module that tracks file changes and fire hooks on the lua side. Works on both Linux and Windows.
- Get premake add it to your
PATH
- Get garrysmod_common (with
git clone https://github.com/danielga/garrysmod_common --recursive --branch=x86-64-support-sourcesdk
) and set an env var calledGARRYSMOD_COMMON
to the path of the local repo - Run
premake5 gmake --gmcommon=$GARRYSMOD_COMMON
in your local copy of this repo - Navigate to the makefile directory (
cd /projects/linux/gmake
orcd /projects/macosx/gmake
) - Run
make config=releasewithsymbols_x86_64
Get one the pre-compiled binaries or build it yourself, then put the binary under garrysmod/lua/bin
.
require('io_events')
hook.Add("FileChanged", "my_hook", function(path, event_type)
if path:EndsWith(".lua") and event_type == "DELETED" then
print("A lua file was removed!")
end
end)
File Change Event Types:
CREATED
the file was just createdCHANGED
the file contents were just modifiedDELETED
the file was just deletedRENAMED_NEW
the file was just renamed, the path is the new path to the fileRENAMED_OLD
the file was just renamed, the path is the old path to the fileUNKNOWN
the file went under some kind of change, but we don't know what it was
Scope:
This module only targets files among your Garry's Mod directory, other files on your system are not part of the scope of this module.