Page 1 of 1

Learn Lua / Love2D with me :)

PostPosted: 15 Apr 2020, 00:38
by Julius
So I decided that it might be nice to learn some lua. No lua doesn't suck: https://youtu.be/LvpDE5z2_XE

Both for simple game dev, but also because the popular XMPP server Prosody is written in lua and I am interested in developing extensions for it.

It seems fairly popular around here as well, especially in the form of Love2D: https://love2d.org
So if you want to help me or just join me in learning it, this is the place. Although a word of warning... I am probably going to be a lot slower than you as I suck :eew:

I'll probably start with this tutorial series: https://sheepolution.com/learn/book/contents

Maybe something from here is interesting as well: http://lua-users.org/wiki/TutorialDirectory

But the medium term goal is to revive this Love2D project and get it to a fun state:
https://github.com/poVoq/opencrypt
https://www.youtube.com/watch?v=_xzpXc8emBE

Or maybe I'll try some Godot project with this: https://github.com/perbone/luascript

Re: Learn Lua / Love2D with me :)

PostPosted: 15 Apr 2020, 01:01
by Julius
Ok first step, get a nice IDE.

There is some discussion what to choose here:
https://love2d.org/forums/viewtopic.php?f=3&t=6915
And a awesome list here: https://github.com/love2d-community/awesome-love2d#ides

I'll probably go with the ATOM IDE: https://atom.io/packages/love-ide
But this looks also interesting: https://studio.zerobrane.com/
(because: http://notebook.kulchenko.com/zerobrane ... -with-love )

Re: Learn Lua / Love2D with me :)

PostPosted: 15 Apr 2020, 02:33
by Julius
Not my cup of tea, but there is a video tutorial set:
https://www.youtube.com/playlist?list=P ... 9aT88KGxH8

Re: Learn Lua / Love2D with me :)

PostPosted: 15 Apr 2020, 10:24
by GunChleoc
You could also look for an active FLOSS game that uses Lua and see if they have beginner's tickets to pick up. Off the top of my head, Wesnoth, Hedgewars, Widelands. There might be more.

Re: Learn Lua / Love2D with me :)

PostPosted: 15 Apr 2020, 18:39
by Julius
Yeah, that would be another good option of course.

For now I went with the Zerobrane IDE as that is what the tutorial uses and I never really got a "favorite" IDE anyways.

Made progress a few chapters in... the lua syntax is a bit unusual but quite easy to learn and remember I think.

Re: Learn Lua / Love2D with me :)

PostPosted: 15 Apr 2020, 20:07
by smcameron
Space Nerds in Space could always use more mission scripts, which are written in Lua. Lua API for it is described here, and some existing scripts are here.

Re: Learn Lua / Love2D with me :)

PostPosted: 16 Apr 2020, 16:15
by Vandar
I haven't installed an IDE yet, beyond the scite editor (a very generic text editor). The client in my latest project (Tiny Places in Showcase forum) uses Lua/Love2d for the client though. I found the Love2d online documentation to be very helpful. So I'm a newby myself, but feel free to ask if you are looking for help :)

Lua favors a style of OOP that is different from what I had been used to in C++ or Java, but I like the approach to use tables to combine data and function pointers a lot. Very easy, very flexible. Reminds me a bit of how Smalltalk did OOP, at least in the way that any object can implement any method and you can just try to call it regardless of the class of the object.

Re: Learn Lua / Love2D with me :)

PostPosted: 16 Apr 2020, 22:49
by Julius
Worked on something else today, but I am still very much committed to this.

Thanks for the suggestions and help offered :)

Re: Learn Lua / Love2D with me :)

PostPosted: 17 Apr 2020, 17:54
by GunChleoc
There are 2 pitfalls around tables:

- Indexing starts at 1 instead of 0
- #table doesn't return the actual number of elements, but the highest index used. This can be misleading if you have gaps in the index.

Re: Learn Lua / Love2D with me :)

PostPosted: 18 Apr 2020, 23:11
by Vandar
GunChleoc {l Wrote}:T
- #table doesn't return the actual number of elements, but the highest index used. This can be misleading if you have gaps in the index.


Even worse. It returns the first index that is followed by a nil, even if there are more entries coming after the gap. My conclusion: do not use the size operator on tables, unless you are 100% sure there are no gaps.

Re: Learn Lua / Love2D with me :)

PostPosted: 20 Apr 2020, 01:34
by Julius
Good to know. But I actually like that indexing starts at 1 :p

Making slow progress with the tutorial, as I am getting distracted with other stuff. But so far so good :heart:

Re: Learn Lua / Love2D with me :)

PostPosted: 21 Apr 2020, 17:34
by GunChleoc
Julius {l Wrote}:Good to know. But I actually like that indexing starts at 1 :p

That's fun until you try to do modular arithmetic on it. Those necessary index shifts by 1 are not fun.

Re: Learn Lua / Love2D with me :)

PostPosted: 22 Apr 2020, 14:38
by Vandar
It's a bit weird indeed. Some old BASIC dialects had an option to choose 0 or 1 as array start.

But can't you just insert elements manually and begin at zero?

{l Code}: {l Select All Code}
  array[0] = someValue
  array[1] = someOtherValue


should be totally legal.

Re: Learn Lua / Love2D with me :)

PostPosted: 22 Apr 2020, 18:40
by GunChleoc
Yes it should, but then you have to remember to do so every time, or write your own array access wrapper functions and use those.

Re: Learn Lua / Love2D with me :)

PostPosted: 26 Apr 2020, 02:55
by Technopeasant
Vandar {l Wrote}:It's a bit weird indeed. Some old BASIC dialects had an option to choose 0 or 1 as array start.


Yes, and Visual Basic .Net and Gambas are both 0 indexed as opposed to classic Visual Basic or QBasic.

Re: Learn Lua / Love2D with me :)

PostPosted: 08 Jun 2020, 13:30
by Julius
Sorry, got sidetracked with other stuff. Still planning to get back to this though.

Found this interesting engine that apparently is build on top of Love2D:
https://github.com/Planimeter/grid-sdk

Re: Learn Lua / Love2D with me :)

PostPosted: 01 Jul 2020, 19:20
by Julius
http://tylerneylon.com/a/learn-lua/

Quick "learn lua in 15 minutes" summary.

Re: Learn Lua / Love2D with me :)

PostPosted: 06 Jul 2020, 15:45
by Julius
Ahh, this looks cool:
https://github.com/a327ex/BYTEPATH
(LÖVE game with tutorial)

Re: Learn Lua / Love2D with me :)

PostPosted: 06 Jul 2020, 15:54
by Julius
Ahh and this (with some plugins) might make for a cool code editor written in lua:
https://github.com/rxi/lite

Re: Learn Lua / Love2D with me :)

PostPosted: 22 Aug 2020, 00:32
by Julius