• Learning Lua and GLua
    43 replies, posted
So you want to code for Garry's Mod, but have no idea where to start. Assuming you have no knowledge of any kind of programming language, Lua is a good place to start because it is a high-level scripting language. Other good programming languages to start with include [URL="http://docs.oracle.com/javase/tutorial/"]Java[/URL], [URL="http://msdn.microsoft.com/en-us/library/aa288436(v=vs.71).aspx"]C#[/URL] (easier than [URL="http://www.cplusplus.com/doc/tutorial/"]C++[/URL]), and [URL="http://docs.python.org/2/tutorial/"]Python[/URL]. Before you start with any programming language, a useful program to have is [URL="http://notepad-plus-plus.org/"]Notepad++[/URL], or [URL="http://www.sublimetext.com/"]Sublime[/URL] with [URL="https://github.com/FPtje/Sublime-GLua-Highlight"]Falco's highlighting for GLua[/URL]. [B]Word and Wordpad will [U]NOT[/U] work.[/B] Notepad will work, however, it's recommended to either use Notepad++ or Sublime for the organization and highlighting. GLua is a modified version of Lua, so you may find it beneficial to learn vanilla Lua first. Here are some great resources for that: - [URL="http://www.lua.org/manual/5.1/manual.html"]Official Reference Manual (5.1)[/URL] -- This is the version Garry's Mod utilizes - [URL="http://www.lua.org/manual/5.3/manual.html"]Official Reference Manual (5.3)[/URL] -- Latest version of Lua - [URL="http://www.lua.org/pil/"]Programming in Lua Book[/URL] - [URL="http://lua-users.org/wiki/LuaTutorial"]Lua Users Tutorial[/URL] - [URL="http://www.lua.org/gems/sample.pdf"]Sample Lua Book[/URL] - [URL="http://luatut.com/"]LuaTut[/URL] - [URL="http://learnxinyminutes.com/docs/lua/"]Learn X in Y[/URL] If you already know Lua, or you would rather go straight into GLua (it's highly recommended you start with some basic Lua first), here are many useful resources: - [URL="http://wiki.garrysmod.com/page/Main_Page"]Official Garry's Mod Wiki[/URL] - [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index4875.html"]Old Garry's Mod Wiki:[/URL] This site has some great tutorials. Use this along with the Official GMod wiki to check if what you are looking at is still valid/unchanged. - [URL="http://samuelmaddock.github.io/glua-docs/"]GLua Docs[/URL] If you are converting old code from past versions of GMod, these are very useful: - [URL="https://docs.google.com/document/d/157blpvgS7-TzierM0WehBGa5W65HGG8ITXcxpYfY2G4/edit"]"Why your scripts are now broken"[/URL] - [URL="https://docs.google.com/document/d/1KJTi7-krLUcJP0ALz8dC5deNdn2-FUcc6WMsRvkYjDw/edit?copiedFromTrash#heading=h.bw8fxkud8bet"]GMod13 File library changes[/URL] If you are a more hands-on person that likes seeing examples, here are some YouTubers that do great tutorials (thanks sm69baller): - [URL="http://www.youtube.com/user/MrCosmicSeagull?feature=watch"]MisterCosmicSeagull[/URL] - [URL="http://www.youtube.com/user/goature?feature=watch"]Goature[/URL] - [URL="http://www.youtube.com/user/chessnutify?feature=watch"]Chessnut[/URL] - [URL="http://www.youtube.com/user/SimonovaSKS"]SimonovaSKS:[/URL] SWEPs & modeling If you want to try Lua in other environments besides Garry's Mod, both [URL="http://www.wowwiki.com/World_of_Warcraft_API"]World of Warcraft[/URL] and [URL="http://wiki.roblox.com/index.php/Scripting"]Roblox[/URL] utilize Lua in very modular ways. [URL="http://en.wikipedia.org/wiki/Category:Lua-scripted_video_games"]Here's a full list of games that utilize Lua[/URL]. Good luck on your learning experience! [B]If you have any suggestions, post them and I'll add them.[/B]
Awesome stuff. In another thread, you mentioned you had some more information besides the 'why your scripts are now broken'. Did you find this in the end?
[QUOTE=NiandraLades;43288567]Awesome stuff. In another thread, you mentioned you had some more information besides the 'why your scripts are now broken'. Did you find this in the end?[/QUOTE] Yes, it was the GMod13 File library changes.
[QUOTE=code_gs;43288588]Yes, it was the GMod13 File library changes.[/QUOTE] Ahh, okay. If you weren't aware, you need to request access to see it.
[QUOTE=NiandraLades;43288630]Ahh, okay. If you weren't aware, you need to request access to see it.[/QUOTE] Fixed it.
add something about using wordpad or word. using one of those programs to code will not work, and i have seen too many people try to.
Most of the people who have added me and asked how to get into lua also asked how to upload stuff to the workshop, so that might be nice to add to the OP. There's also a [url=http://en.wikipedia.org/wiki/Category:Lua-scripted_video_games]Wikipedia page[/url] which lists a lot of games that use lua. Some of the other notable examples being Natural Selection 2, Crysis, Civ 5 and Just Cause 2 Multiplayer.
[QUOTE=bliptec;43289568]Most of the people who have added me and asked how to get into lua also asked how to upload stuff to the workshop, so that might be nice to add to the OP. There's also a [url=http://en.wikipedia.org/wiki/Category:Lua-scripted_video_games]Wikipedia page[/url] which lists a lot of games that use lua. Some of the other notable examples being Natural Selection 2, Crysis, Civ 5 and Just Cause 2 Multiplayer.[/QUOTE] I'll make a tutorial later on how to upload stuff to the workshop (unless someone else already has).
[QUOTE=code_gs;43289584]I'll make a tutorial later on how to upload stuff to the workshop (unless someone else already has).[/QUOTE] Couldn't you just link to the thread garry made about how to do it, maybe adding a bit more emphasis on the fact that people have to compile a gma first? [url]http://facepunch.com/showthread.php?t=1244179[/url]
also add sublime text as a possible coding program since i use it and find it to be better than notepad++, ftpje released an up to date glua syntax plugin for it located here: [url]https://github.com/FPtje/Sublime-GLua-Highlight[/url]
[QUOTE]If you are more hands-on person that likes seeing examples, here are some YouTubers that do great tutorials [B](thanks sm69baller)[/B]:[/QUOTE] Lol no problem ; DD
[QUOTE=legendofrobbo;43294766]also add sublime text as a possible coding program since i use it and find it to be better than notepad++, ftpje released an up to date glua syntax plugin for it located here: [url]https://github.com/FPtje/Sublime-GLua-Highlight[/url][/QUOTE] Added
Great post! I should preface this question by saying that I have no knowledge regarding Lua and GLua. So what are the main differences between the two? And why would one want to skip directly to GLua?
What about sublime text?
[QUOTE=Johnny Guitar;43296516]What about sublime text?[/QUOTE] Added
This looks familiar, lol. Nice work man, this is helpful!
[QUOTE=MrBleepBleep;43296446]Great post! I should preface this question by saying that I have no knowledge regarding Lua and GLua. So what are the main differences between the two? And why would one want to skip directly to GLua?[/QUOTE] Added functions, libraries, etc. You can't really "skip" Lua for GLua since it's still Lua, but one might want to jump straight into GLua if they only plan to use Lua for GMod. I still highly recommend you start with basic Lua first to at least have a preface to what it's about.
This is what I post each time the question arises about learning Lua: Here are some resources which may help you: The Lua manual, this will definitely help you get started! [url]http://www.lua.org/manual/5.1/manual.html[/url] Learn optimization techniques right away to avoid bad habits: [url]http://www.lua.org/gems/sample.pdf[/url] [PAGE 4 -- But read the entire thing] The New Garry's Mod Wiki, has a ton of information, how to use the function calls, how to integrate vgui elements, and more! [url]http://wiki.garrysmod.com[/url] Not everything is on the new Garry's Mod Wiki yet, if it's not there, it's here. There is a lot of things that has changed since Garry's Mod 12, to Garry's Mod 13. This is primarily for 12. [url]http://maurits.tv/data/garrysmod/wik...index4875.html[/url] One of the best places to start, if by modifying TTT. Start by changing the sweps, more realistic fire-rates, balance the damage, add a feature which changes the cone based on if you're moving, firing from the hip, aiming down the sights, crouching, holding the walk button, etc etc. Start small, start by doing simple things and work your way up!
Sublime looks really cool, so I think I might swap over to that, especially if the syntax highlighting is up to date. I really wish there was more physical books about lua, I know there's one or two but if I recall they're quite expensive too. I know it's probably a small market, but I'd love something I could read in college.
[QUOTE=NiandraLades;43356924]Sublime looks really cool, so I think I might swap over to that, especially if the syntax highlighting is up to date. I really wish there was more physical books about lua, I know there's one or two but if I recall they're quite expensive too. I know it's probably a small market, but I'd love something I could read in college.[/QUOTE] PIL (programming in lua) isn't too expensive.
For the people thinking of going with Sublime Text, I switched sometime last year from Notepad++ and I can't go back. Been using the [url=https://github.com/kkga/spacegray]Space Gray[/url] theme and [url=http://blogs.adobe.com/typblography/2012/09/source-code-pro.html]Adobe's Source Code Pro[/url] font and I couldn't recommend those more. I started learning Lua around 2005, and for me learning by example and experimenting was the easiest way - but if I had to do it over, I definitely would have used the PIL, it would have saved me a lot of trouble years down the road.
[url]http://luasearch.remscar.com/[/url] offline? Was a nice little handy function searcher.
[QUOTE=Pantho;43466322][url]http://luasearch.remscar.com/[/url] offline? Was a nice little handy function searcher.[/QUOTE] [url]http://samuelmaddock.github.io/glua-docs/[/url] Is still up and is really nice.
Added new links (thanks cartman300 for the LuaTut link).
[QUOTE=Looter;43468331][url]http://samuelmaddock.github.io/glua-docs/[/url] Is still up and is really nice.[/QUOTE] <3 Thanks.
Thanks man can help me improve alot
Nice this will hopefully help newbies get a grip before they come begging for scripts in dev discussion :D
For more experienced programmers, or people who just need to know the syntax [url]http://learnxinyminutes.com/docs/lua/[/url] is an AMAZING resource
I made [URL="http://facepunch.com/showthread.php?t=1390994"]this[/URL] tutorial on how to make an experience/levelling system, which may be helpful for anyone who already has a basic understanding of Lua.
nice
Sorry, you need to Log In to post a reply to this thread.