How to properly setup Love2D - LUA on Windows 10 ?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
steliosPaf
Prole
Posts: 4
Joined: Sun May 17, 2020 11:20 am

How to properly setup Love2D - LUA on Windows 10 ?

Post by steliosPaf »

Good evening / morning to all.

This is my first time posting here, I've been looking around for an easy answer to my questions but I'm not satisfied so I'm making this post! If this has already been answered repeatedly then by all means, do point me in the right direction!

I'm following CS50's Introduction to Game Dev on edX, which is how I learned about Love2D and so far I'm löving it (pun intended :rofl: ) I managed to complete the first 3 assignments on my own, however I'm still very new to LUA development and something about my setup is really bugging me.

I'm using Windows 10, my editor of choice is Microsoft's VS Code, and I'd like it to stay that way. I'm using GitBash for my terminal but I also have WSL installed and I think, I have installed LUA 5.1 after blindly following some random post I found lying around. Installing LUA might actually be the single hardest thing I never managed to do. My main concerns are:
  • Debugging Love2D projects, namely having something to output to
  • Code styling / LUA support
I'm a little confused regarding my VS Code extensions. Right now I'm just using 'Love2D Support' --by Pixelbyte Studios and Lua --by keyring and I don't have the same visual results as the course instructor, I also tried 'vscode-lua' --by trixnz but I didn't like it. Right now I have zero debug output from my Love2D projects so I'd like to fix that asap, but I can't find anything online. Also I'd like to know what's the optimal way to run LUA on Windows 10, so if anyone could lend me a hand it'd be more than appreciated! I probably failed to mention some important information so, please ask for it, thank you!
AndrewMicallef
Prole
Posts: 7
Joined: Wed Apr 29, 2020 2:37 am

Re: How to properly setup Love2D - LUA on Windows 10 ?

Post by AndrewMicallef »

I'm not sure I have a fix for you, but I can +1 the issue with the vscode love launcher on Wndows. Trying to get my head around why that wasn't working wound up being more expensive than switching to atom editor and using the love launcher package there.

But maybe start with the basic stuff:
Do have a copy of Love.exe in the directory that the VScode extension looks in? Or have you told the extension to look in the right place?

Edit: I re read your post and another thing hit me, did you remember to grab love2d of love2d.org? You don't need an additional lua installation. Love acts as a lua interpreter, so in the words of Mcartny and Lennon, all you need is love.

Edit1: oh and I found setting the --console flag and using print statements to be mighty helpfull on the debugging front
steliosPaf
Prole
Posts: 4
Joined: Sun May 17, 2020 11:20 am

Re: How to properly setup Love2D - LUA on Windows 10 ?

Post by steliosPaf »

AndrewMicallef wrote: Mon May 18, 2020 8:58 pmEdit: I re read your post and another thing hit me, did you remember to grab love2d of love2d.org? You don't need an additional lua installation. Love acts as a lua interpreter, so in the words of Mcartny and Lennon, all you need is love.
I have set Love2D in my PATH environment so I don't have issues running the projects, I use bash to navigate to my project folder and just run 'love .' command to run my main.lua file, but I want to be able to run general purpose .lua files, say for testing purposes. The other day I wanted to try some metatable shenanigans to get a better feel for them, so I had in mind to create a 'someproject.lua' file and just use 'lua someproject.lua' command to run the project but this doesn't work. I hope this makes some sense. For example, I have installed Ubuntu through WSL and I installed LUA 5.3.5 so I can type lua

Code: Select all

stelios@Stelios:~$ lua
Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
>
AndrewMicallef wrote: Mon May 18, 2020 8:58 pm Edit1: oh and I found setting the --console flag and using print statements to be mighty helpfull on the debugging front
Where should I be looking for Love2D output? my terminal shows nothing!!!
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to properly setup Love2D - LUA on Windows 10 ?

Post by pgimeno »

steliosPaf wrote: Mon May 18, 2020 10:33 pm I have set Love2D in my PATH environment so I don't have issues running the projects, I use bash to navigate to my project folder and just run 'love .' command to run my main.lua file, but I want to be able to run general purpose .lua files, say for testing purposes.
What I do is create this main.lua file:

Code: Select all

local x = arg[2]:gsub('%.lua','')
table.remove(arg, 2)
function love.keypressed(k) return k == "escape" and love.event.quit() end
require(x)
Then I run it with: love . filename

That allows me to test different files without the need for creating folders for them. It also allows me to escape with ESC by default.

steliosPaf wrote: Mon May 18, 2020 10:33 pmI have installed Ubuntu through WSL and I installed LUA 5.3.5 so I can type lua

Code: Select all

stelios@Stelios:~$ lua
Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
>
Better install LuaJIT or Lua 5.1 instead of 5.3. Löve uses LuaJIT which is almost 100% compatible with Lua 5.1, but does not have the features of 5.3, therefore you may end up trying a feature in 5.3 that won't work with Löve.

steliosPaf wrote: Mon May 18, 2020 10:33 pm Where should I be looking for Love2D output? my terminal shows nothing!!!
I don't use Windows or VS, but maybe running lovec.exe instead of love.exe helps? You're prining to the terminal with either print() or io.write(), right?
User avatar
4vZEROv
Party member
Posts: 126
Joined: Wed Jan 02, 2019 8:44 pm

Re: How to properly setup Love2D - LUA on Windows 10 ?

Post by 4vZEROv »

I have the Löve launcher extension (by Jan Werber) in my Vscode.
I configured the lovelauncher path variable to point to love.exe

If you open a folder containing a main.lua file, press Alt + L and löve will be launched automatically.
To have a console, create a conf.lua file next to your main.lua and write:

Code: Select all

function love.conf(t)
	t.console = true
end 
You don't need to "install" lua to use löve, but if you want to do it just download the tool executable files from here:
http://luabinaries.sourceforge.net/
And add the folder to your path.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to properly setup Love2D - LUA on Windows 10 ?

Post by zorg »

And while we're at it, to pre-empt a few things;

As far as i know, the CS50 courses use an older version of löve (0.10.something); while you should use the latest (11.3 at the moment) version, you need to be aware that there were quite some changes, most visibly the fact that colors are 0-1 floats now, instead of 0-255 whole numbers.

And lua's not an acronym so don't ALLCAPS it. :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
steliosPaf
Prole
Posts: 4
Joined: Sun May 17, 2020 11:20 am

Re: How to properly setup Love2D - LUA on Windows 10 ?

Post by steliosPaf »

zorg wrote: Tue May 19, 2020 12:59 amAs far as i know, the CS50 courses use an older version of löve (0.10.something); while you should use the latest (11.3 at the moment) version, you need to be aware that there were quite some changes, most visibly the fact that colors are 0-1 floats now, instead of 0-255 whole numbers.
Yes I'm indeed using 11.3 and I'm aware of some changes, thanks for noticing nontheless.
pgimeno wrote: Mon May 18, 2020 11:18 pmBetter install LuaJIT or Lua 5.1 instead of 5.3. Löve uses LuaJIT which is almost 100% compatible with Lua 5.1, but does not have the features of 5.3, therefore you may end up trying a feature in 5.3 that won't work with Löve.

I don't use Windows or VS, but maybe running lovec.exe instead of love.exe helps? You're prining to the terminal with either print() or io.write(), right?
Is it really a good move starting on a older Lua version?
Yes I tried running some print functions but I get no output. After my initial post yesterday I tried looking into my WSL installation. So if I run VSCode from within Ubuntu terminal, everything seems to be working fine. I can run whatever .lua file by typing

Code: Select all

lua randomfile.lua
and the output seems to be there as well, so I might just stick with WSL before I move completely to Linux actually.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: How to properly setup Love2D - LUA on Windows 10 ?

Post by pgimeno »

steliosPaf wrote: Tue May 19, 2020 10:23 am Is it really a good move starting on a older Lua version?
LuaJIT only supports 5.1, and the speed advantage is overwhelming (often 20x). Many projects would not even be possible with the normal Lua interpreter.
steliosPaf
Prole
Posts: 4
Joined: Sun May 17, 2020 11:20 am

Re: How to properly setup Love2D - LUA on Windows 10 ?

Post by steliosPaf »

Ok thank you all for your time, I'll research a bit more on the matter once I become more familiar with Lua
Digitalbill
Prole
Posts: 1
Joined: Mon Nov 11, 2024 8:11 pm

Re: How to properly setup Love2D - LUA on Windows 10 ?

Post by Digitalbill »

I just went through this issue and got it to work and here is what i can tell you if you are running into this problem. Install the vs plug by Jan. Then and this is important uninstall any other love vs code plugin that you have installed. I uninstalled all the other ones and then for just LUA i left one plugin installed which was just called LUA by Sumneko and that is it. Once I saved it, I hit Alt + L and whammy it worked. So do not forget to remove the other plugins because they seem to conflict and prevent this shortcut from working. :awesome:
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests