Reloading a lua script with 'lua_openscript'

Hi. I’m trying to reload some of my scripts in my addons folder without changing the map or restarting the game.

Script path: garrysmod\addons estfolder\lua\myScript\script.lua

Didn’t work:


] lua_openscript_cl "testfolder\lua\myScript\script.lua"                                                               
] lua_openscript_cl testfolder\lua\myScript\script.lua                                           
] lua_openscript testfolder\lua\myScript\script.lua  
                                                                   
] lua_openscript testfolder/lua/myScript/script.lua                                     
] lua_openscript_cl testfolder/lua/myScript/script.lua                                                      
] lua_openscript_cl "testfolder/lua/myScript/script.lua"
                                                                            
] lua_openscript_cl "myScript/script.lua"                               
] lua_openscript_cl myScript/script.lua                                       
] lua_openscript myScript/script.lua
] lua_openscript "myScript/script.lua"

] lua_openscript "myScript\script.lua"                                                                            
] lua_openscript myScript\script.lua
] lua_openscript_cl myScript\script.lua 
] lua_openscript_cl "myScript\script.lua"

I always get this error: Couldn’t include file ‘…’ (File not found) (<nowhere>)

Those files are relative to the lua folder right?

] lua_openscript_cl myScript/script.lua
] lua_openscript myScript/script.lua

Should work. Try removing the capitals from the folder name.

If you’re trying to open a lua script server-side, use lua_openscript, if you’re trying to open a lua script client-side, use lua_openscript_cl.

And the path is always relative to the lua folder.

Gmod 13:


RunString( file.Read( "addons	estfolder\lua\myScript\script.lua", "GAME" ))

Gmod 12:


RunString( file.Read( "addons	estfolder\lua\myScript\script.lua", true ))

Run that lua, and it should work…

Also, you’re not ‘reloading’ the script rather you’re running the script multiple times. So keep that in mind.

Edit:
This might not have the desired result but adapt the method to your code.