Help conceptualizing loops/pattern matching
Posted: Tue May 17, 2016 2:19 pm
Hi all,
I'm just starting with Lua and have a very basic understanding of html and javascript. I know that loops exist and are essential, but I'm having a hard time conceptualizing what is going on.
Specifically, I'm currently going through this tutorial, https://github.com/kikito/love-tile-tut ... 1d-strings, on Github that is focusing on building a 2d map on love. The full source code for this section is here: https://github.com/kikito/love-tile-tut ... s/main.lua.
I'm guessing that this is pretty simple code for non-beginners, so I'm just going to ask a few questions about it instead of posting specific lines.
I understand what's going on in the top part of love.load(), but the bottom part (TileTable() and below) is very perplexing. So:
1.What is the best way to visualize/explain what the for loops are executing? I'm thinking in circles trying to understand the logic.
2.What is the code doing with the gmatch:("[\n]+") and gmatch:(".") commands? The tutorial briefly calls it pattern matching, but I have yet to figure out what exactly that means.
3.I think I understand the loops in love.draw(), but at the same time I don't think I really understand it. An explanation of those loops would be incredible.
If there are any other good resources for getting a better understanding of loops, etc. please feel free to share!
Thanks!
I'm just starting with Lua and have a very basic understanding of html and javascript. I know that loops exist and are essential, but I'm having a hard time conceptualizing what is going on.
Specifically, I'm currently going through this tutorial, https://github.com/kikito/love-tile-tut ... 1d-strings, on Github that is focusing on building a 2d map on love. The full source code for this section is here: https://github.com/kikito/love-tile-tut ... s/main.lua.
I'm guessing that this is pretty simple code for non-beginners, so I'm just going to ask a few questions about it instead of posting specific lines.
I understand what's going on in the top part of love.load(), but the bottom part (TileTable() and below) is very perplexing. So:
1.What is the best way to visualize/explain what the for loops are executing? I'm thinking in circles trying to understand the logic.
2.What is the code doing with the gmatch:("[\n]+") and gmatch:(".") commands? The tutorial briefly calls it pattern matching, but I have yet to figure out what exactly that means.
3.I think I understand the loops in love.draw(), but at the same time I don't think I really understand it. An explanation of those loops would be incredible.
If there are any other good resources for getting a better understanding of loops, etc. please feel free to share!
Thanks!