Created
September 5, 2019 02:24
-
-
Save doyousketch2/dc235583e02f6dc9df5197e0ed2458b9 to your computer and use it in GitHub Desktop.
Run your Lua / Love2D scripts within gEdit -- F5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/dash | |
# [Gedit Tool] | |
# Name=Run Lua / Love2D | |
# Languages=lua | |
# Shortcut=F5 | |
# Input=nothing | |
# Output=output-panel | |
# Applicability=local | |
# Save-files=document | |
## place in ~/.config/gedit/tools/ | |
## usually only name my Love2D scripts "main.lua" so this method works well. | |
## other Lua scripts will execute w/ your system Lua instead. | |
looking_for_lua=true | |
if [ -e main.lua ] ; then ## try current dir | |
looking_for_lua=false | |
love . | |
else if [ -e ../main.lua ] ; then ## try parent dir | |
looking_for_lua=false | |
love ../. | |
else if [ -e ../../main.lua ] ; then ## try grandparent dir | |
looking_for_lua=false | |
love ../../. | |
else if [ -e ../../../main.lua ] ; then ## one more for good measure | |
looking_for_lua=false | |
love ../../../. | |
fi | |
fi | |
fi | |
fi | |
## haven't found a Love2D script, try running it in Lua instead | |
if [ $looking_for_lua ] ; then | |
lua $GEDIT_CURRENT_DOCUMENT_PATH | |
fi | |
## You can nest the "main.lua" search further than 4 deep if you really need to, | |
## but this seems to suit my purpose. I wouldn't want it traversing | |
## nonstop up the filesystem hunting for something that doesn't exist. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment