• include("config.lua") does not work
    5 replies, posted
I saw many addons that have a seperate lua file, named config or whatever, so people can change some settings easily, settings that you let them change of course...the way i thought it works is you put the variables (or stuff to change) in the config.lua, and then in other luas that need those variables, you make include("config.lua") (config.lua is the path to the lua of course) But everytime it never works. I dont even get a error. The variables are just nil because they never get passed from the config. What am i doing wrong? I really need the config to work to get my addon to working proberbly
Could you post your config?
Are they local? Is the file even running? Did you include it and "AddCSFile'd" it? https://wiki.garrysmod.com/page/Global/AddCSLuaFile include Script_Name = {} Script_Name.Config = {} Script_Name.Config.Some_Option = true Script_Name.Config.Some_Option_2 = 6
//This Config includes the Settings for DarkRP and TTT. Only change the Parameters in the way the Comments tell you. local ShouldRangBeShown = true --------------------------- --         DarkRP        -- --------------------------- local RPWantedCheck = true local RPMoneyCheck  = true --------------------------- --          TTT          -- --------------------------- The Config only includes a few variables, so you can set yourself if the scoreboard should show Wanted, Money, Rang etc. in the scoreboard code itself everything has a if check, like if ShouldRangBeShown == true then --Simple text, showing the rang end Which never gets shown because ShouldRangBeShown is not true. HOWEVER if i make the check running if ShouldRangBeShown == nil, then it shows since..its nil. cause the config does not get included
A local variable can only be referenced inside the file/scope that it was defined in.
ok that table stuff there just confused me now...
Sorry, you need to Log In to post a reply to this thread.