Hello there, I'm working a gamemode. I tried to setup a Lua reload system because the GNU/Linux version of Garry's Mod (dedicated server) is missing that feature. So, I went and did a bit of research and came to the conclusion that you had to call include/AddCSLuaFIle on all the files you would like to refresh again. However, I can't get the damn thing to work, from what I can tell the server updates but the client does not.
Anywho, the gamemode is setup like this:
[B]Files[/B]
[LUA]
placeholder/gamemode
init.lua
cl_init.lua
shared.lua (empty except for GM.Version, GM.Name, GM.Author)
placeholder/gamemode/modules
cl_debug.lua
[/LUA]
[B]placeholder/gamemode/init.lua[/B]
[LUA]
include( "shared.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_init.lua" )
local gamemode_directory = "placeholder/gamemode/modules/"
-- Load server files
local files, directories = file.Find( gamemode_directory .. "sv_*", "LUA" )
for k, v in pairs( files ) do
include( gamemode_directory .. v )
print( "Loaded " .. v )
end
-- Inform the server to send clientside files to clients
local files, directories = file.Find( gamemode_directory .. "cl_*", "LUA" )
for k, v in pairs( files ) do
AddCSLuaFile( gamemode_directory .. v )
print( "Prepared " .. v )
end
-- Load shared files to the server, inform the server to send them to clients
local files, directories = file.Find( gamemode_directory .. "sh_*", "LUA" )
for k, v in pairs( files ) do
include( gamemode_directory .. v )
AddCSLuaFile( gamemode_directory .. v )
print( "Loaded (server) and prepared" .. v )
end
[/LUA]
[B]placeholder/gamemode/cl_init.lua[/B]
[LUA]
include( "shared.lua" )
local gamemode_directory = "placeholder/gamemode/modules/"
-- Load clientside files
local files, directories = file.Find( gamemode_directory .. "cl_*", "LUA" )
for k, v in pairs( files ) do
include( gamemode_directory .. v )
print( "Loaded " .. v )
end
-- Load shared files
local files, directories = file.Find( gamemode_directory .. "sh_*", "LUA" )
for k, v in pairs( files ) do
include( gamemode_directory .. v )
print( "Loaded " .. v )
end
[/LUA]
[B]placeholder/gamemode/modules/cl_debug.lua[/B]
[LUA]
hook.Add( "HUDPaint", "module_debugging", function()
draw.RoundedBox( 0, 0, 0, 100, 100, Color( 0, 0, 0, 255) )
end )
[/LUA]
I then merged everything into a shared function and added a concommand.
[B]placeholder/gamemode/init.lua[/B]
[LUA]
include( "shared.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_init.lua" )
[/LUA]
[B]placeholder/gamemode/cl_init.lua[/B]
[LUA]
include( "shared.lua" )
[/LUA]
[B]placeholder/gamemode/shared.lua[/B]
[LUA]
function load_modules()
if ( SERVER ) then
local gamemode_directory = "placeholder/gamemode/modules/"
-- Load server files
local files, directories = file.Find( gamemode_directory .. "sv_*", "LUA" )
for k, v in pairs( files ) do
include( gamemode_directory .. v )
print( "Loaded " .. v )
end
-- Inform the server to send clientside files to clients
local files, directories = file.Find( gamemode_directory .. "cl_*", "LUA" )
for k, v in pairs( files ) do
AddCSLuaFile( gamemode_directory .. v )
print( "Prepared " .. v )
end
-- Load shared files to the server, inform the server to send them to clients
local files, directories = file.Find( gamemode_directory .. "sh_*", "LUA" )
for k, v in pairs( files ) do
include( gamemode_directory .. v )
AddCSLuaFile( gamemode_directory .. v )
print( "Loaded (server) and prepared" .. v )
end
else
local gamemode_directory = "placeholder/gamemode/modules/"
-- Load clientside files
local files, directories = file.Find( gamemode_directory .. "cl_*", "LUA" )
for k, v in pairs( files ) do
include( gamemode_directory .. v )
print( "Loaded " .. v )
end
-- Load shared files
local files, directories = file.Find( gamemode_directory .. "sh_*", "LUA" )
for k, v in pairs( files ) do
include( gamemode_directory .. v )
print( "Loaded " .. v )
end
end
end
load_modules()
concommand.Add( "load_modules", load_modules )
[/LUA]
I then joined the server, the HUD loads normally. I edited the HUD file then ran load_modules on both the client and server for good measure. I get an output on both the client and server that the file has been loaded, but the HUD does not change, even if I reconnect. If it matters, I am also using the GNU/Linux Garry's Mod client. I would appreciate any help, thank you.
Autorefresh doesn't work on Linux, you need to do a map change each time you make a change.
[QUOTE=meharryp;46879829]Autorefresh doesn't work on Linux, you need to do a map change each time you make a change.[/QUOTE]
He is aware, its in the first line of the post. He is trying to a workaround method in order to get it to refresh
Bump, surely someone has also run into this problem. Am I doing something obviously wrong?
Well, perhaps someone will write a module for it eventually... but I wouldn't expect it quickly
Take a look at my autoloader:
If you're looking for an "empty" game-mode to start developing on ( for creating addons in an environment meant for dev work, developing a new game-mode, etc... ) which has a lot of building-blocks to make development easier, and dev-tools for debugging, etc.. I recommend running my dev-base ( supports smart-autorefresh for Linux or Windows with -disableluarefresh )
AcecoolDev_Base Skeletonized Game-Mode ( Never worry about Include or AddCSLuaFile ever again; comes with New Hooks, Console Commands, Meta-Table Objects, Helper Functions, Extended Functionality, and more! )
AcecoolDev_Networking: Only has the networking and data system with required files. Also has UMSG to NetMSG Conversion Mapper and will eventually include NW/DT/etc.. Var map through networking system...
AcecoolDev_Base Addon - All of the features above, but packaged as an addon.
Find out more and Download here: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/___welcome_docs/_welcome_acecooldev_base_gamemode_info.lua.html[/url]
----------
If you don't have auto-refresh or it is disabled on Windows, you can enable the "smart" auto-refresh which will reload any files that were updated since they were loaded when loadgm is called... I am working on updating the autoloader to build in a few optimizations and to fix an issue where if you use "smart" auto-refresh it won't update the files for new joiners. It works if you remain connected so it works for dev servers. When I'm done with it, if my fix or new autoloader doesn't fix it, I'll save a list of files that were updated in order so they can be updated when a client connects.
With the optimizations it'll reload files a lot faster than it currently does by removing the need to re-categorize realm each load plus a few other things. But, even with it doing that, the "smart" auto-refresh runs a lot faster because it reloads 1 to x files that have changed.
[QUOTE=Netheous;46888987]Well, perhaps someone will write a module for it eventually... but I wouldn't expect it quickly[/QUOTE]
The problem is in File::ChangeMonitor in [URL="https://github.com/garrynewman/bootil"]Bootil[/URL], however checking the GitHub for that, it seems [URL="https://github.com/garrynewman/bootil/pull/1"]a patch was introduced to fix it for Linux[/URL], but I guess garry broke it again since.
[QUOTE=Acecool;46889266]Reply[/QUOTE]
This fixed the problem. From what I can gather, files are not sent with AddCSLuaFile except the first time around when you join the server. I'll file a bug report for the Garry's Mod team.
Sorry, you need to Log In to post a reply to this thread.