From 6230510b2ebabd0c72ad0653cb18f70af359b79e Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Wed, 17 Mar 2021 20:06:02 +0800 Subject: [PATCH] =?UTF-8?q?cmd=E6=96=B0=E5=A2=9Eprint=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E8=BE=93=E5=87=BA=E4=B8=80=E6=95=B4=E4=B8=AA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/app_cmd.lua | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/parts/scenes/app_cmd.lua b/parts/scenes/app_cmd.lua index e54037b0..20557c7a 100644 --- a/parts/scenes/app_cmd.lua +++ b/parts/scenes/app_cmd.lua @@ -46,7 +46,7 @@ do--commands.help(arg) "Usage: #[lua_source_code]", "", "print() can be used to print text into this window.", - "There is a strange box.", + "[A secret can be found]", }, }, exit={ @@ -64,11 +64,17 @@ do--commands.help(arg) details={ "Print a message to this window.", "", - "Aliases: echo print", - "", "Usage: echo [message]", }, - },print="echo", + }, + print={ + description="Print a file to this window.", + details={ + "Print a file to this window.", + "", + "Usage: print [filename]", + }, + }, url={ description="Attempt to open a URL with your device.", details={ @@ -213,6 +219,7 @@ do--commands.help(arg) "#", "exit", "echo", + "print", "url", "tree", "del", @@ -275,6 +282,26 @@ function commands.echo(str) outputBox:push(str) end end +function commands.print(name) + if name~=""then + local info=love.filesystem.getInfo(name) + if info then + if info.type=="file"then + log{COLOR.lC,"/* "..name.." */"} + for l in love.filesystem.lines(name)do + log(l) + end + log{COLOR.lC,"/* END */"} + else + log("Unprintable item: %s (%s)"):format(name,info.type) + end + else + log{C.R,"No file called '"..name.."'"} + end + else + log{C.water,"Usage: del [filename]"} + end +end function commands.url(url) if url~=""then local res,err=pcall(love.system.openURL,url)