mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-28 00:39:30 +00:00
Moved library path modifications to main.lua, made all paths relative
The library path can now be easlily modified. Instead of always launching /3ds/ctruLua/main.lua, ctruLua will now launch the main.lua in the current directory (the ctruLua.3dsx directory when launched with HBL). On citra, this will be the root of the sdmc directory.
This commit is contained in:
parent
81f8edb25d
commit
0efdc23576
6 changed files with 49 additions and 21 deletions
|
|
@ -3,8 +3,8 @@ local hid = require("ctr.hid")
|
|||
local gfx = require("ctr.gfx")
|
||||
|
||||
-- Open libs
|
||||
local keyboard = dofile("sdmc:/3ds/ctruLua/keyboard.lua")
|
||||
local openfile = dofile("sdmc:/3ds/ctruLua/openfile.lua")
|
||||
local keyboard = require("keyboard")
|
||||
local openfile = require("openfile")
|
||||
local color = dofile("color.lua")
|
||||
local syntax = dofile("syntax.lua")
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ local syntax = dofile("syntax.lua")
|
|||
local font = gfx.font.load("VeraMono.ttf")
|
||||
|
||||
-- Open file
|
||||
local path, status = openfile("Choose a file to edit", "/3ds/ctruLua/", nil, "any")
|
||||
local path, status = openfile("Choose a file to edit", nil, nil, "any")
|
||||
if not path then return end
|
||||
local lineEnding
|
||||
local lines = {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
local fs = require("ctr.fs")
|
||||
|
||||
-- Set up path
|
||||
local ldir = fs.getDirectory().."libs/"
|
||||
package.path = package.path..";".. ldir.."?.lua;".. ldir.."?/init.lua"
|
||||
|
||||
repeat
|
||||
fs.setDirectory("sdmc:/3ds/ctruLua")
|
||||
local file = dofile("openfile.lua")("Choose a Lua file to execute", "/3ds/ctruLua/", ".lua", "exist")
|
||||
local file = require("openfile")("Choose a Lua file to execute", nil, ".lua", "exist")
|
||||
if file then
|
||||
fs.setDirectory(file:match("^(.-)[^/]*$"))
|
||||
dofile(file)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
--- Open a file explorer to select a file.
|
||||
-- string title: title of the file explorer.
|
||||
-- string curdir: the directory to initially open the file explorer in.
|
||||
-- string curdir: the directory to initially open the file explorer in, or nil for the current directory.
|
||||
-- string exts: the file extensions the user can select, separated by ";". If nil, all extensions are accepted.
|
||||
-- string type: "exist" to select an existing file, "new" to select an non-existing file or "any" to select a existing
|
||||
-- or non-existing file name. If nil, defaults to "exist".
|
||||
|
|
@ -11,9 +11,10 @@ return function(title, curdir, exts, type)
|
|||
local ctr = require("ctr")
|
||||
local gfx = require("ctr.gfx")
|
||||
|
||||
local keyboard = dofile("sdmc:/3ds/ctruLua/keyboard.lua")
|
||||
local keyboard = require("keyboard")
|
||||
|
||||
-- Arguments
|
||||
local curdir = curdir or ctr.fs.getDirectory()
|
||||
local type = type or "exist"
|
||||
|
||||
-- Variables
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue