Dear,
I can only imagine how many times a day you see a noob such as myself, get on these forums, asking the same question - how do I learn lua?
However, after doing some research, I know the very basics of Lua. I believe that I will learn over time, when I begin making scripts. So I was wondering, can anyone give me a VERY simple "task", that I'd try to complete. For example, you suggest I "make a printer" (No idea how hard that is).
Then I try to actually make it, making use of the wiki and the internet. If I come across problems I REALLY don't know how to solve, I'll just ask here, but I'll try to refrain from asking every single thing I do not understand.
I have no specific reason as to learn GLua/Lua at the moment; I just feel like it would be good to contribute (in the far future) to the game that has given me many fun moments, and just broaden my horizons in general.
Thanks in advance,
Brem.
I would recommend checking out this thread and try some of these challenges:
[url]https://facepunch.com/showthread.php?t=1487912[/url]
Also, try creating some challenges for yourself. Think of simple things you'd like to create, such as a derma menu or a SWEP. Look at already existing addons and scripts to see how they do things and get some inspiration from that, use the wiki to look up things you don't know.
If you haven't already I would really suggest giving this a read as well:
[url]https://www.lua.org/pil/[/url]
That's kind of the issue. I do not know what is doable and what not, for my level of experience (very low). Thats why id like to take on requests from the FP community, starting with very easy things, and then slowly expanding into bigger projects.
[QUOTE=BremFM;51510026]That's kind of the issue. I do not know what is doable and what not, for my level of experience (very low). Thats why id like to take on requests from the FP community, starting with very easy things, and then slowly expanding into bigger projects.[/QUOTE]
Go on code cadamy and learn Ruby. It's similar since they're both OOP languages. You can the go to Code Blues channel on YT. He explains it pretty well. Or just hire someone, like RayChamp.
[QUOTE=FlyPiggyBanks;51510252]It's similar since they're both OOP languages.[/QUOTE]
ruby and lua are not OOP languages at all, you can do oop but they don't have the features other languages have for it
[QUOTE=meharryp;51510522]ruby and lua are not OOP languages at all, you can do oop but they don't have the features other languages have for it[/QUOTE]
ruby is and does
Since it sounds like you haven't actually started doing anything yet a "very simple task" I would suggest is get a basic swep working. From there you have limitless possibilities. I think the first thing I did was make a gun that shot 5 bullets at once. You can try anything. Make a swep that makes you invisible. Make one that temporarily blinds whoever you shoot.
Apart from getting a basic swep working, get a basic entity working (showing in the spawn menu and spawning correctly). Then you can do anything again. Make an entity that when you use it, it spawns ammo entities. Making entities make entities can get to really interesting places. Make a bomb that spawns more bombs. Or a bomb that spawns bananas.
You can really do anything.
[QUOTE=BremFM;51510026]That's kind of the issue. I do not know what is doable and what not, for my level of experience (very low). Thats why id like to take on requests from the FP community, starting with very easy things, and then slowly expanding into bigger projects.[/QUOTE]
The thread Jocken300 linked you is exactly what you need. [url]https://facepunch.com/showthread.php?t=1487912[/url]
[QUOTE=BremFM;51509973]how do I learn lua?[/QUOTE]
Just think of something that you think would be cool in Garry's Mod. Don't think about how difficult it might be to make, just try to think of a cool idea that you actually want to do.
It'll be much more fun than doing some random thing on a thread that you probably won't get much enjoyment out of, and you'll learn a lot along the way
[QUOTE=zerf;51510887]ruby is and does[/QUOTE]
*Cough* 5 Disagrees and 2 dumbs, you pretty much agree with me and get 2 agrees from two people who disagreed with me.
Makes sense...
I don't think anyone here understands the fact that this guy doesn't know how to program or any programming fundamentals. So like I said before, go learn Ruby on CodeCadmy. You can't just jump right into Lua if you don't know how to program.
After you completed the Ruby course and have a good grip on the fundamentals (tables, if/else/ifelse, functions, etc), then you can ease yourself into Lua.
Or as I otherwise stated, hire someone to teach you. So you can have 1 on 1 and the teacher will be able to point out all your mistakes.
[QUOTE=FlyPiggyBanks;51512415]*Cough* 5 Disagrees and 2 dumbs, you pretty much agree with me and get 2 agrees from two people who disagreed with me.
Makes sense...
I don't think anyone here understands the fact that this guy doesn't know how to program or any programming fundamentals. So like I said before, go learn Ruby on CodeCadmy. You can't just jump right into Lua if you don't know how to program.
After you completed the Ruby course and have a good grip on the fundamentals (tables, if/else/ifelse, functions, etc), then you can ease yourself into Lua.
Or as I otherwise stated, hire someone to teach you. So you can have 1 on 1 and the teacher will be able to point out all your mistakes.[/QUOTE]
Any programming language can be someone's first programming language, there's NO reason to have to learn Ruby before learning Lua.
The absolutely best way to learn to program is to make stuff you actually like. Making gmod addons if you like gmod is the [b][i]perfect[/i][/b] motivation for learning and progressing. Ruby on the other hand would be a boring joyless effort to learn a programming language that maybe, if he's lucky, he [i]might[/i] be able to use once or twice in the future. Lua is a language he wants to be using [i]now[/i].
I rated you dumb because the "advice" you gave is completely counter-beneficial for the one asking, and doesn't answer his question at all. I imagine that everyone else who rated you feels the same.
We're not out to get you, you're just wrong in this particular case.
[QUOTE=NeatNit;51512503]Any programming language can be someone's first programming language, there's NO reason to have to learn Ruby before learning Lua.
The absolutely best way to learn to program is to make stuff you actually like. Making gmod addons if you like gmod is the [b][i]perfect[/i][/b] motivation for learning and progressing. Ruby on the other hand would be a boring joyless effort to learn a programming language that maybe, if he's lucky, he [i]might[/i] be able to use once or twice in the future. Lua is a language he wants to be using [i]now[/i].
I rated you dumb because the "advice" you gave is completely counter-beneficial for the one asking, and doesn't answer his question at all. I imagine that everyone else who rated you feels the same.
We're not out to get you, you're just wrong in this particular case.[/QUOTE]
Eyyyyy, wanna know why he should learn Ruby before Lua?
Because *cough* he asked for an interactive tutorial. Which *cough* CodeCadamy provides.
Also, Lua isn't for people who have 0 programming experience. This guy, I assume, has none. He would be better off learning Ruby first because it will give him the knowledge of fundamentals in programming while also at the same time having an online, interactive interpreter.
He could always use Gmod but besides reading from a book, he wouldn't really learn why the syntax is like that, he would just learn "It just has to be like that. I dunno why, it just is". In Ruby he can. It makes learning Lua, and other languages that are OOP, a lot easier.
To simplify this, I don't believe he wants to learn Lua specifically, what I think he wants to do is learn how to PROGRAM in Lua. Meaning he must first learn how programming works before he starts learning how to do it in Lua. Ruby in CodeCadamy teaches you that. In my opinion, a lot better than an online text guide.
To prove my point, he is still asking the same question from a year ago.
[QUOTE=BremFM;48788245]Dear,
Today I decided to try to learn lua. I am familiair with PHP and I know the most basic code languages HTML and CSS. I' ve been using this [URL="http://www.phailed.me/2011/02/learn-lua-the-hard-way-1/"]tutorial[/URL], and lua doesn't seem to be too hard. Has anyone got a link for me on all the things that GLua adds to the traditional lua?
Kind regards,
Brem.[/QUOTE]
[QUOTE=MPan1;51512027]Just think of something that you think would be cool in Garry's Mod. Don't think about how difficult it might be to make, just try to think of a cool idea that you actually want to do.
It'll be much more fun than doing some random thing on a thread that you probably won't get much enjoyment out of, and you'll learn a lot along the way[/QUOTE]
Actually me when I made my first crafting system (was modifying a crappy one) :v:
[editline]11th December 2016[/editline]
[QUOTE=FlyPiggyBanks;51512746]want to say something funnier than snip but I can't think anything so, snip[/QUOTE]
I did learn Lua from scratch, many difficulties but so far so good
[editline]11th December 2016[/editline]
Plus in my point, Lua is easier for beginner instead of C, which is many people's first language
[QUOTE=YoutoYokodera;51512762]Actually me when I made my first crafting system (was modifying a crappy one) :v:
[editline]11th December 2016[/editline]
I did learn Lua from scratch, many difficulties but so far so good
[editline]11th December 2016[/editline]
Plus in my point, Lua is easier for beginner instead of C, which is many people's first language[/QUOTE]
What did you quote me on? I don't remember posting that.
Also Lua from scratch as in nothing or scratch as in the drag n' drop code like a pro?
Ruby was my first language. Helped me learn a lot about the basics of programming and understand other languages a lot better.
[QUOTE=FlyPiggyBanks;51512776]What did you quote me on? I don't remember posting that.
Also Lua from scratch as in nothing or scratch as in the drag n' drop code like a pro?[/QUOTE]
I changed the quote so it look funnier than snip
And it's from nothing, I just read people's code, look into WAYWO and take that as my motivation
[QUOTE=FlyPiggyBanks;51512746]
Also, Lua isn't for people who have 0 programming experience.[/QUOTE]
i literally had no experience when I started lua, now, i aint amazing but i know enough to handle some shit ;)
if anything, i feel like glua is a good language to start with, because it's fun working with it on a platform such as Garry's Mod.
just don't stick to glua for the rest of your life, try stretching out and learning other shit :D
[QUOTE=Tupac;51512787]i literally had no experience when I started lua, now, i aint amazing but i know enough to handle some shit ;)
if anything, i feel like glua is a good language to start with, because it's fun working with it on a platform such as Garry's Mod.
just don't stick to glua for the rest of your life, try stretching out and learning other shit :D[/QUOTE]
Yo script look awesome though I haven't had paypal to buy shit :(
[QUOTE=Tupac;51512787]i literally had no experience when I started lua, now, i aint amazing but i know enough to handle some shit ;)
if anything, i feel like glua is a good language to start with, because it's fun working with it on a platform such as Garry's Mod.
just don't stick to glua for the rest of your life, try stretching out and learning other shit :D[/QUOTE]
Maybe, but I am giving him advice on how I did it. I think he would be better off if he did it the way I did.
It's obvious that reading from online guides isn't working for him. So maybe instead of doing it the way everyone has been telling him to do it (which is go read the guides and test it in gmod), he could try it my way.
[QUOTE=FlyPiggyBanks;51512415]*Cough* 5 Disagrees and 2 dumbs, you pretty much agree with me and get 2 agrees from two people who disagreed with me.
[/QUOTE]
Also you should watch out or you might be banned for care about rating
[editline]11th December 2016[/editline]
Oh you just broke my merge :(
Well your suggest isn't look bad either
Gonna take a look at Ruby
[QUOTE=YoutoYokodera;51512815]Also you should watch out or you might be banned for care about rating
[editline]11th December 2016[/editline]
Oh you just broke my merge :(
Well your suggest isn't look bad either
Gonna take a look at Ruby[/QUOTE]
I don't care about ratings, I was pointing out hypocrisy.
Alright enough derailing
About the OP I think you should just do what you like
There is nothing better if you do what you are into in, have passion with it, you will learn more than forcing yourself to do what you don't like to
And read WAYWO, they have lots of motivation :3
You raised some valid points, most prominently the post from over a year ago (mind linking to that by the way? you should have quoted it ;/)
Either way, let's let BremFM decide what to do, we've given him enough advice :D
I don't know about you guys, but I kinda saw Garry's Mod [I]as[/I] an interactive tutorial back when I started. You simply tab out and save your changes, and the game would automatically update and point out errors if there are any. My suggestion is to use the Beginner Challenges thread or set up your own tasks, then trying to make them using the wiki and other scripts for reference. Also learning to understand errors is a very good first step, since they can let you know exactly what's wrong and where.
I forgot to mention, I have prior experience with programming languages. I know the very basics of PHP, and tiny its 'n bits of Java (I quit learning Java because it was slow and boring and stinky)
So today I have made that "chair shooting" scripts, but then with minor changes to it.
Instead of chairs, it shoots melons and frying pans. I also upped the force to make melons break on impact.
Now I want to make the melons explode on impact, albeit that I have no idea where to start.
I followed the tutorial on the official GLua wiki, but I did not copy-paste it. I typed everything by hand, hoping to learn from it. While I understand what I am typing and why that works, I would not be able to re-construct a script with the same purpose. Aka, I comprehend it, but do not know how to write it.
[spoiler][code]SWEP.PrintName = "Melon Machine"
SWEP.Author = "( Bram)"
SWEP.Instructions = "Shoot melons 'n frying pans!"
SWEP.Spawnable = true
SWEP.AdminOnly = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Slot = 1
SWEP.SlotPos = 2
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = true
SWEP.ViewModel = "models/weapons/v_RPG.mdl"
SWEP.WorldModel = "models/weapons/w_rocket_launcher.mdl"
local ShootSound = Sound( "Metal.SawbladeStick" )
function SWEP:PrimaryAttack()
self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )
self:FireMelon( "models/props_junk/watermelon01.mdl" )
end
function SWEP:SecondaryAttack()
self:FireMelon( "models/props_interiors/pot02a.mdl" )
end
function SWEP:FireMelon( model_file )
self:EmitSound( ShootSound )
if ( CLIENT ) then return end
local ent = ents.Create( "prop_physics" )
if ( !IsValid( ent ) ) then return end
ent:SetModel( model_file )
ent:SetPos( self.Owner:EyePos() + ( self.Owner:GetAimVector() * 16 ) )
ent:SetAngles( self.Owner:EyeAngles() )
ent:Spawn()
--
local phys = ent:GetPhysicsObject()
if ( !IsValid( phys ) ) then ent:Remove() return end
local velocity = self.Owner:GetAimVector()
velocity = velocity * 100000
velocity = velocity + ( VectorRand() * 10 )
phys:ApplyForceCenter( velocity )
cleanup.Add( self.Owner, "props", ent )
undo.Create( "Thrown_Chair" )
undo.AddEntity( ent )
undo.SetPlayer( self.Owner )
undo.Finish()
end
[/code]
[/spoiler]
I found this on the wiki
[code]
function ENT:ImpactTrace( trace, dmgtype, customimpactname )
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
util.Effect( "Explosion", effectdata )
return true
end
[/code]
but I do not know if this is even the correct things.
Help'd be appreciated (and thanks for all the help/advice given so far aswell :) )
Yours sincerely,
BremFM
[QUOTE=NeatNit;51512503]Any programming language can be someone's first programming language, there's NO reason to have to learn Ruby before learning Lua.
[/QUOTE]
I'll always disagree with this every time it comes up. I really believe you need to know pointers to be able to program, and languages like Lua, Ruby, and Python do their absolute best to hide pointers from you. Anecdotally, I never really grasped pointers until I took a class that used C, and suddenly I understood why my shit never worked. Without understanding pointers, It's a common mistake to think
[code]
local a = 1
local b = {}
b.myvalue = 1
local function set_to_three(something)
something = 3
end
local function set_to_three2(something)
something.myvalue = 3
end
set_to_three(a)
set_to_three2(b)
print(a)
print(b.myvalue)
[/code]
Will print out 1, 1. And it's hard to explain why that's not true without going into reference types versus value types.
I know I'm a dirty heretic, but I really recommend C as a first language, [URL="http://www.bloodshed.net/devcpp.html"]DevC++[/URL] comes with a C compiler, and will install it for you. [URL="https://www.tutorialspoint.com/cprogramming/"]Tutorialspoint [/URL] allows you to try running stuff without even installing anything. The C standard library is small enough you can memorize most of it in an afternoon, and once you wrap your head around pointers, everything else suddenly makes a whole lot of sense.
[QUOTE=Apickx;51513357]I'll always disagree with this every time it comes up. I really believe you need to know pointers to be able to program, and languages like Lua, Ruby, and Python do their absolute best to hide pointers from you. Anecdotally, I never really grasped pointers until I took a class that used C, and suddenly I understood why my shit never worked. Without understanding pointers, It's a common mistake to think
[code]
local a = 1
local b = {}
b.myvalue = 1
local function set_to_three(something)
something = 3
end
local function set_to_three2(something)
something.myvalue = 3
end
set_to_three(a)
set_to_three2(b)
print(a)
print(b.myvalue)
[/code]
Will print out 1, 1. And it's hard to explain why that's not true without going into reference types versus value types.
I know I'm a dirty heretic, but I really recommend C as a first language, [URL="http://www.bloodshed.net/devcpp.html"]DevC++[/URL] comes with a C compiler, and will install it for you. [URL="https://www.tutorialspoint.com/cprogramming/"]Tutorialspoint [/URL] allows you to try running stuff without even installing anything. The C standard library is small enough you can memorize most of it in an afternoon, and once you wrap your head around pointers, everything else suddenly makes a whole lot of sense.[/QUOTE]
What? No one will think that will print out 1,1. Is this supposed to be something new? All I see are two functions that change the intial values of the a,b vars to 3. What was the point of this?
Edit*
I just read up on pointers. So technically you're right. Lua, Ruby and Python hide pointers from you.....if you're BLIND.
[QUOTE=FlyPiggyBanks;51513397]What? No one will think that will print out 1,1. Is this supposed to be something new? All I see are two functions that change the intial values of the a,b vars to 3. What was the point of this?
Edit*
I just read up on pointers. So technically you're right. Lua, Ruby and Python hide pointers from you.....if you're BLIND.[/QUOTE]
a and b.myvalue do not end up being 3.
But it's totally reasonable to think that they might.
This is my point.
[QUOTE=Apickx;51513482]a and b.myvalue do not end up being 3.[/QUOTE]
actually, one does :v:
[T]https://feen.us/hppa.png[/T]
the shitty example you provided has more to do with knowing the difference between mutable and immutable objects than it does with knowing pointers and reference types.
[QUOTE=ZeBull;51513501]actually, one does :v:
[T]https://feen.us/hppa.png[/T]
the shitty example you provided has more to do with knowing the difference between mutable and immutable objects than it does with knowing pointers and reference types.[/QUOTE]
[QUOTE=Apickx;51513482]a [B]and[/B] b.myvalue do not end up being 3.
But it's totally reasonable to think that they might.
This is my point.[/QUOTE]
Common, we're supposed to be programmers, we should be able to do this.
Of course one does, but without understanding what's going on, you might be confused as to why one ends up being 1 and the other ends up being 3.
The only immutable "thing" in lua is userdata*, there is nothing immutable in my example. In one case you're mutating a reference type, in the other you're mutating a value type.
You might be able to make a case saying strings are immutable, but eh.
Hey, don't wanna interrupt your fight and all, but I think if you guys had putten less effort in trying to make your point through the creation of scripts, and instead had decided to help me with my problem, I may have had the solution by now :pudge:
Sorry, you need to Log In to post a reply to this thread.