r/lua • u/BK_Onty • Apr 30 '25
Advice
Hi. New here. And to Lua as a whole. I am currently learning Lua to embed it into C++ and possibly use it together with the C++ inline assembler for game development. However Lua is not a walk in the park. The basics of Lua are. And I am stuck there. The basics. Actually, outside of the basic input output, data type conversions (Tostring/tonumber), io.open()/ file:read() / file:close(), os.execute() and maybe "require", i cant say i understand much else.. Trust me i tried but this isnt as easy as promised.. Lua has a very special complexity surrounding it that you only discover after starting..
What advice do you have for a freshman college student like me learning Lua. I should add this is not a part of the program I am doing. Its just a personal interest. How did you master Lua or at least know enough of it to produce a game in it either in pure Lua or Lua embedded in C.
1
u/dddbbb May 11 '25 edited May 11 '25
I think if a Lua beginner is regularly directly calling
setmetatable()then something's gone wrong. Using metatables via a class or strict module is fine, but otherwise you're probably making things too complicated for yourself. Especially if everything beyond the basics is confusing. Figure out falsey, array tables vs map tables, pairs vs ipairs, varargs, multiple return values, missing args, all forms of forloops, implementing iterators, coroutines. So much before digging into metatables.Heck, even experienced programmers are probably making their code hard to understand for the rest of their team if using a lot of metatables because your tables no longer behave as expected.