[Notepad++] Launch Project From Any File

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Helvecta
Party member
Posts: 167
Joined: Wed Sep 26, 2012 6:35 pm

[Notepad++] Launch Project From Any File

Post by Helvecta »

Howdy :crazy:

For Notepad++ users, here's a quick post about how to launch your LOVE2D project from any open file under that project's directory. In short, no more of this:
Familiar error screen wrote:boot.lua:479: No code to run
Your game might be packaged incorrectly.
Make sure main.lua is at the top level of the zip.
1.) Install Notepad++
2.) Install NppExec through Plugins > Plugins Admin...
3.) Press F6 to execute a command, and paste the following:

Code: Select all

NPP_CONSOLE 0
powershell.exe -command "$path = '$(FULL_CURRENT_PATH)'; $file = 'main.lua'; while($path -and !(Test-Path (Join-Path $path $file))){ if($path -eq ((Split-Path -Path $path -Qualifier)+'\')){ break } else { $path = Split-Path $path -Parent } } & 'C:\Program Files\LOVE\love.exe' $path;"
4.) Click "Save..." and enter a name. Click "Save" to execute and save that script for future use.
5.) From NppExec's advanced options (Plugins > NppExec > Advanced Options...), choose your saved script from the "Associated script:" dropdown, then click "Add/Modify".
6.) Still within NppExec's advanced options, select your newly made entry from the "Menu Items *" section, then check the "Place to the Macros submenu" checkbox.
7.) Restart Notepad++.
8.) From within the shortcut mapping tool (Settings > Shortcut Mapper...), go to the "Plugin commands" tab, then find your entry at the bottom. Assign a shortcut to this entry.

You will now be able to use your new shortcut to launch the project, as long as main.lua is in the current directory or a parent directory. For me, this has proven a more effective method than the wiki's currently recommended solution.
"Bump." -CMFIend420
User avatar
YounYokel
Prole
Posts: 39
Joined: Thu Oct 03, 2019 5:57 pm

Re: [Notepad++] Launch Project From Any File

Post by YounYokel »

Very good. One thing you can add in "Execute" option is this at the begging:

Code: Select all

NPP_SAVE
It will save the project.
Last edited by YounYokel on Fri Oct 30, 2020 6:07 pm, edited 4 times in total.
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: [Notepad++] Launch Project From Any File

Post by ivan »

This is a great idea!
Here is my version using just Lua/Love2d (without NppExec):

1.) Download "ezload.love" and save it somewhere
2.) Install Notepad++
3.) Press F5 and enter the command:

Code: Select all

C:\path\to\love.exe C:\path\to\ezload.love -console -fused "$(FULL_CURRENT_PATH)"
Note that "-console" and "-fused" are optional (and make sure to use one dash "-" instead of two "--")
4.) Click "Save..." and enter a name. Click "Save" to execute and save that script for future use.

That's it!
Notepad++ will automatically find and run your project based on the current file you are editing.
Attachments
ezload.love
(677 Bytes) Downloaded 463 times
User avatar
YounYokel
Prole
Posts: 39
Joined: Thu Oct 03, 2019 5:57 pm

Re: [Notepad++] Launch Project From Any File

Post by YounYokel »

You could also bind a key to current file's folder with CMD, and then run love . or lovec . commands if you added the LOVE location in your environment variables list.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot] and 1 guest