Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Works on windows,
- Running using cmd:
- start /d "path\to\lua5X\folder" lua5X.exe path\to\love2d\folder ./
- Running using notepad++:
- Insert into shortcuts.xml (Key "112" = alt, running as alt + f1):
- <Command name="Run as LOVE2d" Ctrl="no" Alt="yes" Shift="no" Key="112">
- path\to\lua5X.exe path\to\thisScript.lua path\to\LOVE2d\folder $(CURRENT_DIRECTORY)
- </Command>
- example:
- <Command...>C:\lua5.3\lua53.exe C:\script\runner.lua C:\LOVE\LOVE_0.10 $(CURRENT_DIRECTORY)</Command>
- ]]
- function fileExists(path)
- local success, f = pcall(io.open, path,"r")
- return f and io.close(f) and true
- end
- -- Checking interpreter
- interprepath = arg[1] or os.exit()
- -- Init path
- projpath = arg[2] and arg[2]:gsub('\\', '/') or os.exit()
- projpath = projpath:sub(-1) == '/' and projpath:sub(1, -2) or projpath
- -- Run debug when any additional flags
- dbg = arg[3] and true or false
- -- Finding folder with 'main.lua'-file
- while projpath:find('/') do
- if fileExists(projpath..'/main.lua') then
- os.execute('start /d "'..interprepath..'" love.exe '..projpath)
- break
- end
- -- Up to the Folder Tree!
- projpath = projpath:match('(.*)%/')
- end
- if dbg then
- for k, v in pairs(arg) do
- print(k..': '..v)
- end
- end
- os.exit()
Add Comment
Please, Sign In to add comment