So, im writing an addon. The main majority of the code is in sv_-snip-.lua which is in -snip-/lua/autorun/server/ . I want to have a settings file, at first im trying to get it work in the same folder. so settings.lua in -snip-/lua/autorun/server/ . Heres my requires:
[CODE]local Settings = require( "serversettings")[/CODE]
In the actual settings file I create a table which all of the settings and return it. However heres the error im getting
[CODE]Couldn't include file 'includes/modules/serversettings.lua' (File not found) (@addons/-snip-/lua/autorun/server/sv_-snip-.lua [/CODE]
Is this includes within the /-snip-/includes/modules? or is it trying to use the main GMOD one? Can someone please explain the lua dot notation way of requiring files?
Don't put your addons files into autorun. Make a "loader" script in autorun and put the rest of your files into something like lua/myaddon/myfiles.lua.
You include the files with include(), not require().
RobotBoy can you explain the file directory system. So if my addons in Garrysmod/Addons/AddonName and I want my Code to be in Garrysmod/Addons/AddonName/lua/maincode/cheese.lua what do i put as the arguements for include().
include("maincode/cheese.lua")
Thanks!
Sorry, you need to Log In to post a reply to this thread.