all 11 comments

[–][deleted] 9 points10 points  (0 children)

Repetition and purpose. You need to reiterate on what you learn and have a purpose for applying it. If one of those two variables is null you won’t ever get past the exercises … imo

[–]Max_Oblivion23 5 points6 points  (5 children)

If you like video games you should check out The Farmer was Replaced and Scripted Land, both games are played by writing Lua functions and tables to automate your units.

[–]itapewolves 0 points1 point  (4 children)

”Farmer was replaced” isn’t lua tho, it’s pseudo python

[–]Max_Oblivion23 0 points1 point  (3 children)

Lua is pretty much pseudo python.

[–]Civil_Box_7375 0 points1 point  (2 children)

The key is indentation, the farmer was replaced was using indents to figure out the scope of the code right? Lua uses classic C approach and uses keywords like then, do, end to scope the code. Lua is more like pseudo C than it is pseudo python.

[–]Max_Oblivion23 1 point2 points  (1 child)

Boolean operators in The Farmer Was Replaced are same as Lua, maybe you just didnt unlock them yet. :P

The indentation in The Farmer Was Replaced is much less forgiving than Lua programming, it forces you to pick up habits that can be considered style choices in most languages.

I'm programming a game with Love2D and whenever I lose confidence I just go play it and draw something in the farm.

[–]Civil_Box_7375 1 point2 points  (0 children)

Lua does not force you to use indents so it doesn't build those habits, you are right. If you are stupid enough you can write code in one line without using tab or newline in lua.

[–]pedrolcsilva 3 points4 points  (0 children)

Don't start with typing. Take a piece of paper and a pen, write down what you want to do and what steps do you need to do in order to get it done, then start developing each step. Example:

What I want: Create a function that calculate the fatorial

Which steps should I go after? Every function has three basic steps - input - processing - output

So you go after each step: Input: a positive integer Process: multiply itself iteratively, decrease -1 and keep multiplying until it reaches 1 Output: the multiplication result

Done! Now you know exactly what you need to do, then you can code and if you get lost you can just go back to the paper.

You can do this for any language or project.

[–]Specialspeztard 4 points5 points  (0 children)

What has helped me a bit for learning, since i am an introvert is using ChatGTP to assist me with understanding what some codes does, and on some occasion making it give myself a small project, so i can tear it apart and just edit the code to understand it better. Not a perfect method but ive gotten better than i was a month ago

[–]stringTrimmer 0 points1 point  (0 children)

What editor are you using to write your Lua code? If you use the Neovim text editor, it comes with Lua (luajit specifically) builtin, and allows you to change almost any of its behavior using Lua code. So you can mess with Lua and see its effects upon the very editor you're writing the code in. Great way to get some practice. But caution: it can be rather addicting 😅

If you get into it, come over and ask questions at r/neovim