Open SabryPhys opened 4 years ago
Please provide more details... how did you attempt to run in. What operating system are you running? Do you have LOVE2D installed? Did you add LUA plugin (Lua - keyring.lua)? If you have LOVE2D installed you should be able to run the game by dropping the ENTIRE FOLDER containing particular main.lua onto love.exe or the shortcut to it. For example you can drop pong-0 onto love.exe to get the code running in love2d. However the current git repo is using an outdated version of push.lua, so if you download the latest love2d version (11.3 as of now) you will still get an error. You need to update push.lua to v.0.4 to get the code running if everything else has been installed correctly.
I am using Windows 10, and i have visual studio 2017, when noticed that the instructor is using visual studio, i searched google for an extension for running love2D into visual studio, https://marketplace.visualstudio.com/items?itemName=pixelbyte-studios.pixelbyte-love2d
when i clicked install it opens visual studio code window, in fact i am not sure if the plugin installed correctly or not, when first time i pressed F5 to run the code, t asked my about the interpreter, and i chosen Lua, and it starts running, as if the code stops at a break point or something at line 23, and an orange status bar down the window show no messages, then i pressed F5 again, and it gave me this message Exception has occurred: [C]:-1: attempt to index a nil value (global 'love') stack traceback: main.lua:29: in main chunk [C]: in ?
In fact, it will be very helpful and time saving if there is a step by step instruction and compile and run the code indifferent IDE's
and here is a new error message
Unfortunately it is not possible to run the game using the 'run code' feature in VSC. You can run in using the terminal window in VSC but would need to either type out the full path to the love.exe each time or add love.exe to the win10 'path': https://love2d.org/wiki/PATH Then you would be able to use keyword 'love' instead of the full path.
There is a Love2d tutorial here: https://love2d.org/wiki/Getting_Started You may want to fallow this one and use one of the IDE's recommended by them.
You still need to make sure that you have the Love2d game engine installed, if you do try dropping the folder containing main.lua file onto love.exe and let me know what happens.
I installed a few plugins and run/debug Love with VSCode on Windows 10, if it helps this is how my setup looks:
Install Visual Studio Code
Install LOVE
Open VSCode, select Extensions on left menu toolbar (5th item down)
Install Extension "Love2D Support" (pixelbyte studios)
Install Extension "Local Lua Debugger" (Tom Blind)
Install Extension "Lua" (keyring.lua)
Select Explorer on left toolbar, open editor to your LOVE sources
Add these two lines to the top of your main.lua to enable the debugger when you launch with debug.
if pcall(require, "lldebugger") then require("lldebugger").start() end if pcall(require, "mobdebug") then require("mobdebug").start() end
Select Run on left menu toolbar (4th item down)
Select the "settings cog" next to Debug LOVE which should open a launch.json file. Set the program command to the appropriate path to LOVE. ie. Windows something like "C:\Program Files\LOVE\love.exe" or Macos, "/Applications/love.app/Contents/MacOS/love". an example launch.json shown below.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lua-local",
"request": "launch",
"name": "Debug LOVE",
"program":
{
"command": "C:\\Program Files\\LOVE\\love.exe"
},
"args":
[
"${workspaceFolder}",
"vsc_debug"
],
},
]
}
I did not install local lua debuger extension so I cannot advise of this one. However I think you may be trying to run Love2D as if it was a lua debuger, and it is obviously not. If you have the pixelbyte Love2D extension enabled then try doing the following and let me know what happens:
I was replying to the original question by SabryPhys explaining how I successfully use Visual Studio Code (on both Windows 10 an MacOS) to launch and debug my assignments from inside Visual Studio Code.
The if conditions I added in step 8 are only necessary if you wish to use the debugger, set breakpoints and see callstacks. Yes, Love2d is not a lua debugger but after the Love2D process launches specified by the command location in the configuration profile, it runs your main.lua and those if conditions allow Visual Studio Code to connect the debugger to the Lua process if you launched with the debugger. They are ignored if you launch with the regular run button. The lua-local configuration profile is what enables this facility and it made learning and troubleshooting my Love2d program more enjoyable.
Thank you for clarifying. In that case this does look lie a helpful tool and I might look into using it myself!
I installed a few plugins and run/debug Love with VSCode on Windows 10, if it helps this is how my setup looks:
- Install Visual Studio Code
- Install LOVE
- Open VSCode, select Extensions on left menu toolbar (5th item down)
- Install Extension "Love2D Support" (pixelbyte studios)
- Install Extension "Local Lua Debugger" (Tom Blind)
- Install Extension "Lua" (keyring.lua)
- Select Explorer on left toolbar, open editor to your LOVE sources
- Add these two lines to the top of your main.lua to enable the debugger when you launch with debug. if pcall(require, "lldebugger") then require("lldebugger").start() end if pcall(require, "mobdebug") then require("mobdebug").start() end
- Select Run on left menu toolbar (4th item down)
- Select the "settings cog" next to Debug LOVE which should open a launch.json file. Set the program command to the appropriate path to LOVE. ie. Windows something like "C:\Program Files\LOVE\love.exe" or Macos, "/Applications/love.app/Contents/MacOS/love". an example launch.json shown below.
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "lua-local", "request": "launch", "name": "Debug LOVE", "program": { "command": "C:\\Program Files\\LOVE\\love.exe" }, "args": [ "${workspaceFolder}", "vsc_debug" ], }, ] }
Thanks for the information. I just changed ${workspaceFolder}
to ${relativeFileDirname}
since my workspace includes all of the files for the course. I just open the main.lua file in vs code and then click execute and it will run in that directory.
I am using visual studio code, as the instructor in first lecture, but it didn't work and i got this message Exception has occurred: [C]:-1: attempt to index a nil value (global 'love') stack traceback: main.lua:29: in main chunk [C]: in ?