Lua Tutorial Series, it confuses the heck out of me at a certain point.

I get stuck at “The For Loop” on the tutorial series.
I’m only 12, and this is damn hard for a person like me, I’m going to attempt at it again later this year, and hopefully get it, but is it unusual for someone to not be able to understand it?

Also, in the series, they go to these functions and stuff, I wonder how the hell I’m going to find all these different functions, and how to put it all together.

How does it confuse you?

for i=1,5 do

It runs 5 times, starting at one and ending at five.

For functions, I use

You do have to have a general knowledge of certain functions, for example you MUST know that LocalPlayer refers to the player running the script.

Coding is damn hard when your first starting out. I got through the initial hump by thinking to myself, “This is just like learning french, only precision of language is a MUST.”, you have to know the functions before hand for
to be useful, even then its nothing special.

Remove the www. -

Yeah, sorry. A small mistake.

What is it you don’t understand? We can help.

I’m in a similar position as the OP. I decided to start learning Lua today. I spent about 4 hours going through the wiki tutorial, trying to understand as much as possible. After the tutorial though, I didn’t really know how to progress further, so I tried (very basically) to make a SWEP based on others, but it was kind of like jumping in the deep end and a lot of it went over my head. :frowning: Any advice on where to go from here?

It might be helpful for the OP to know that he’s not the only one who finds the wiki tutorial confusing at times!

For learning I’ve always found editing helped me, get something, see it work and think of a way to change it. Like take the sent_ball that comes with gmod and make it bounce higher, or kill things on touch, and just read the info on the functions that make it work as you go, and then the ones you need to make the change. Don’t go releasing it or anything, just to learn from. Trying to read the entire wiki and remember it is hard, but if you can learn by applying it might be easier. Hope this helps.

Download this:

Go in-game and start running the code you find on the wiki, edit it, think what might happen, run it. Did what you predict happen? If so, good job, otherwise try to understand why the outcome is different.

The gmod tutorials are not where you should be looking.

Gmod lua isn’t practical for learning - you should be doing console stuff for the for loops etc.

Also to the person that posted first, stfu - if somebody can’t understand a concept there’s absolutely no need for that kind of demotivating attitude; it really winds me up when people come to this section with bugger all knowledge acting cool when somebody is new.

If either of you feel the need, hit me up on steam, I’ll answer questions to the best of my ability.

Well, a year or so ago, I used to make weapons for a Flood Server, using Resource.AddFile to add models, etc. etc. but that is really it.
Sometimes, I edit values of lua code, etc. etc.

[editline]30th January 2011[/editline]

Well, all I could say was, I took code off of the SENT_Ball, and code off of another entity, and made an armor entity for DarkRP, which gives 100 Armor to whoever uses it, I made sure it had a V:Physics model or whatever, so it didn’t act like a bouncy ball, change SetHealth to SetArmor, etc. etc.

isnt it something like

[LUA] for VALUE = StartNumber , EndNumber then … [/LUA]

Not then.


[lua]for n = 1, 100 do

prints 1 to 100.

n can be anything. I just prefer N. And so do a lot of other people.

[editline]30th January 2011[/editline]

> for n = 1, 5 then print(“hi”) end…
[lua_run:1] ‘do’ expected near ‘then’

for n = 1, 10000 do

a lot more fun

Considering you’ve managed all this without learning about basic syntax like loops, I’m guessing you did it by copy-pasting blocks of code from other things?

Basically the same as spamming a link. You’ll just restart the progress every time…

Pretty much… Is that bad? :ohdear:

Thanks for the advice, I’ll start messing about with existing code then, see if I can change it correctly :slight_smile: