Garry's Mod can't even find the script I'm attempting to run
10 replies, posted
I have a folder in addons named unit > lua. Theres 6 scripts in the lua folder
>c_to_f.lua
>f_to_c.lua
>mph_to_kmh.lua
>kmh_to_mph.lua
>print.lua
>string.lua
This is the output i get in the console every time i try to run lua_openscript f_to_c.lua
] lua_openscript f_to_c.lua
Running script f_to_c.lua...
Couldn't include file 'f_to_c.lua' (File not found) (<nowhere>)
Contents of the script I'm trying to run:
AddCSLuaFile("f_to_c.lua")
local f = math.random(160)
local c = (f - 32) * 5 / 9 print(f .." F")
print(c .." C")
I'm still new to scripting on Garry's Mod but I have some experience with Lua from coding on Roblox for so long.
I've only ever had this problem if I've added a new file system into addons without restarting the server, if you have done that i can only assume its because you're mixing up what your doing on client vs. server (why are you using 'AddCSLuaFile' ??)
I honestly don't know why I'm adding "AddCSLuaFile"
And I have restarted the server when I have added new files to the folder, though it still doesn't fix anything.
If you're putting it in the addons folder your structure should look something like this.
addons\youraddonname\lua\autorun\client\my_cl_script.lua
addons\youraddonname\lua\autorun\server\my_sv_script.lua
addons\youraddonname\lua\autorun\my_sh_script.lua
Are you running "lua_openscript" on the server console or on your clients console ingame?
Client console, ingame
you're mixing up client and server, you need to do the AddCSLuaFile on the server before you try to run it on client (add a lua file in autorun\server and add all your files with it), you should also be using the 'lua_openscript_cl' command on client (wouldn't recommend this [tho I've never tried doing this] ). watch the videos MrRalgoman posted and make the scripts auto run, then put your functions into a concommand function instead of separate lua files.
Tried putting all the code in one script with "concommand.Add" inside of lua > autorun > client folder. It works but trying to run other scripts like this
hook.Add("HUDPaint", "DrawMyHud", function()
draw.RoundedBox(0,0,0,100,100,Color(0,255,255))
end)
will just error out when i try to run it on the client with lua_openscript_cl command.
I get this error whenever i try to execute a client script (with lua_openscript_cl)
] lua_openscript_cl hook.add
Running script hook.add...
Couldn't include file 'hook.add' (File not found) (<nowhere>)
[Proud American Medic Main|2|STEAM_0:0:26886042] Lua Error:
Couldn't include file 'hook.add' (File not found) (<nowhere>)
Lua run cl
Because the path is lua_openscript_cl autorun/client/hook.add.lua
It works now, thanks.
Sorry, you need to Log In to post a reply to this thread.