• Lua Scripts Saving Help
    40 replies, posted
Hello, I've just started to learn how to LUA script today off of the Gmod Wiki Tutorials (I started like an hour ago, but I've made it past this into the variables scrips but I need to fix this problem to go any farther.) and for some reason my script wont run. When I make the script [code]Msg("Hello World!")[/code] and save it into G:\New Folder\steamapps\killover509\garrysmod\garrysmod\lua (That's the path for me, that's not the problem) and then when I start up Garrysmod, go to Singleplayer and in the console I type lua_openscript helloworld.lua the console says [code]Running script helloworld.lua... Couldn't include file 'helloworld.lua' (File not found) (<nowhere>)[/code] I've tried making a folder inside of garrysmod\garrysmod\lua and saving it into that but that didn't change anything, just the same message. How can I fix this? [editline]dsdsd[/editline] And yes I saved it as 'All Files'
Anyone?
The only two reasons i can think of as to why that's happening is either there's a problem with your game or the file isn't where you think it is. Browse to the directory, make sure it's in: [B]<gmod base dir>\lua\helloworld.lua[/B]. The lua script should really be encoded in ANSI (The default for most text editors) but can also be encoded UTF-8 as long as it's without a BOM (byte order mark). If all else fails, put the script in [B]lua\autorun[/B] and the file will run automatically (This is not ideal but can be used as a final resort).
You need to use the HLDS.
I've browsed into \lua\helloworld.lua and made sure it's there, it's encoded with ANSI, and when I put it in lua\autorun but still, same thing. Weird. I'll try loading the script in a multiplayer server and see if that works. [editline]15th July 2011[/editline] nope
[QUOTE=killover;31140482]I've browsed into \lua\helloworld.lua and made sure it's there, it's encoded with ANSI, and when I put it in lua\autorun but still, same thing. Weird. I'll try loading the script in a multiplayer server and see if that works. [editline]15th July 2011[/editline] nope[/QUOTE] Try to using Notepad++ And Encode with (UTF-8 Without BOM) . i wish it helps ([url]http://wiki.garrysmod.com/?title=Getting_Started_With_Lua[/url])
[QUOTE=cyw960517;31141756]Try to using Notepad++ And Encode with (UTF-8 Without BOM) . i wish it helps ([url]http://wiki.garrysmod.com/?title=Getting_Started_With_Lua[/url])[/QUOTE] I'm already using Notepad++, but was using ANSI, I'll try that. Also I didn't know about that page so that helped too, thanks. :buddy: I'll check if this works now. [editline]15th July 2011[/editline] Nope, doesn't work. Do you think reinstalling Garrysmod would fix it?
[QUOTE=killover;31142474]I'm already using Notepad++, but was using ANSI, I'll try that. Also I didn't know about that page so that helped too, thanks. :buddy: I'll check if this works now. [editline]15th July 2011[/editline] Nope, doesn't work. Do you think reinstalling Garrysmod would fix it?[/QUOTE] [img]http://cfile215.uf.daum.net/image/132878524E20E9240C5796[/img] [img]http://cfile240.uf.daum.net/image/1949DF4A4E2105272DFFA1[/img] (It should be like this.)
I would recommend the LuaPad addon, you can obtain it at garrysmod.org.
[QUOTE=cyw960517;31133013]You need to use the HLDS.[/QUOTE] What the fuck. Also, could you give us a screenie of where you're putting the script?
[QUOTE=cyw960517;31144600][img]http://cfile215.uf.daum.net/image/132878524E20E9240C5796[/img] [img]http://blogfiles.naver.net/20110716_261/cyw960517_1310780172788rhiQg_PNG/14.png[/img] (It should be like this.)[/QUOTE] What do you mean? [editline]15th July 2011[/editline] [QUOTE=jrj996;31145242]What the fuck. Also, could you give us a screenie of where you're putting the script?[/QUOTE] Alright, one minute. [editline]15th July 2011[/editline] [IMG]http://img801.imageshack.us/img801/6681/luascriptplace.png[/IMG] If you cant see it, the path is G:\New Folder\steamapps\killover509\garrysmod\garrysmod\lua
[QUOTE=killover;31145296]What do you mean? [editline]15th July 2011[/editline] Alright, one minute. [editline]15th July 2011[/editline] [IMG]http://img801.imageshack.us/img801/6681/luascriptplace.png[/IMG] If you cant see it, the path is G:\New Folder\steamapps\killover509\garrysmod\garrysmod\lua[/QUOTE] [img]http://cfile240.uf.daum.net/image/1949DF4A4E2105272DFFA1[/img] it should be appeared to the console. [editline]16th July 2011[/editline] [QUOTE=killover;31145296]What do you mean? [editline]15th July 2011[/editline] Alright, one minute. [editline]15th July 2011[/editline] [IMG]http://img801.imageshack.us/img801/6681/luascriptplace.png[/IMG] If you cant see it, the path is G:\New Folder\steamapps\killover509\garrysmod\garrysmod\lua[/QUOTE] [img]http://cfile240.uf.daum.net/original/1949DF4A4E2105272DFFA1[/img] it should be appear
I know but it's because for some reason gmod can't find the file.
Wait, did you write it with notepad?..
[QUOTE=jrj996;31146936]Wait, did you write it with notepad?..[/QUOTE] Notepad++
[QUOTE=killover;31147024]Notepad++[/QUOTE] You need to use The dedicated Server.
[QUOTE=cyw960517;31147167]You need to use The dedicated Server.[/QUOTE] What do you mean? Like a dedicated server on Garrysmod?
[QUOTE=killover;31147631]What do you mean? Like a dedicated server on Garrysmod?[/QUOTE] Yes (HldsUpdateTool)
>.<' It's not working because it's sending it to the serverside console so ofc you aren't getting it. Try using Print
[QUOTE=InfernalCookie;31147799]>.<' It's not working because it's sending it to the serverside console so ofc you aren't getting it. Try using Print[/QUOTE] What do you mean by Print? Like Msg Printing because if that's what you mean I don't know what you mean because that's a function. (Like Msg ( "Hello" ))
[QUOTE=cyw960517;31147718]Yes (HldsUpdateTool)[/QUOTE] No you dont.
Don't use luapad, just save the file and openscript.
[QUOTE=_NewBee;31148560]Don't use luapad, just save the file and openscript.[/QUOTE] I don't use Luapad I use Notepad++ and save it then try and run it on the garrysmod console but it says it can't find it but the file is in garrysmod\lua
Try putting this into your console, tell us what it returns: [code] lua_run print(tostring(file.Exists("lua/helloworld.lua", true))) [/code]
This is what it gave me [code]> print(tostring(file.Exists("lua/helloworld.lua", true)))... false[/code]
Which means the game cannot see the file for some reason. Try making sure that the file doesn't have any attributes that might cause problems i.e. hidden or compressed, and make sure the directory isn't hidden either. Are you sure that you are definately running GMod from that directory?
Just checked, the directory (and helloworld.lua) aren't hidden or compressed and yes I'm 100% sure I'm running Gmod from this directory.
Okay, try this. If this returns false, then for some reason the game cannot access the lua folder: [code] lua_run print(tostring(file.IsDir("../../garrysmod/garrysmod/lua", true))) [/code]
[QUOTE=cyw960517;31147718]Yes (HldsUpdateTool)[/QUOTE] What the hell are you talking about?
[QUOTE=jrj996;31151752]What the hell are you talking about?[/QUOTE] He meant SRCDS.
Sorry, you need to Log In to post a reply to this thread.