Including Files

Hello,

So I have an error appearing in my console, yet it doesn’t make sense. Here’s my best at explaining it.

Inside the addon is lua/autorun then a client folder, a server folder and config.lua file. Inside the config.lua file I have [LUA] AddCSLuaFile() [/LUA] Inside my server folder is a file called sv_sp1.lua at the top of this file I’ve put [LUA] include( “config.lua” ) [/LUA]
Inside my config the user can change the chat command to open the menu, obviously the server file reads to the config file to see what the chat command should be. When I change the chat command it works, but it still prints this in console

Couldn’t include file ‘config.lua’ (File not found) (@addons/multi_server_portal/lua/autorun/server/sv_sp2.lua (line 2))

Any help would be awesome, if you want to actually see the files, just ask I’ll post them.

Thanks.

  1. Name your files uniquely so they don’t get overridden by other addons
  2. Make sure the file you are trying to include is not empty

The server is including the config file which isn’t empty. I’m testing it on singleplayer where I’m not using any other addons. So I doubt the file name is that same as another file.

So you are here:
lua/autorun/server/sv_sp2.lua

and trying to include the file in here?

lua/autorun/config.lua

If that’s the case:

  1. include(“config.lua”) will look for the file in the lua/autorun/server/
  2. All files in autorun/ folder are automatically included, hence the name “autorun”. This includes all files in /client/ and in /server/ folders.

I am trying to include the config.lua file in lua/autorun are you saying I don’t need to add the include( “config.lua” ) in the server file and it will still ‘read’ the config file?

[editline]25th August 2015[/editline]

Ahh it does still read it. Thank you very much.