整理代码(user670升级的cmd小程序)

This commit is contained in:
MrZ626
2021-03-08 02:07:48 +08:00
parent df0be2468e
commit d034be1aff

View File

@@ -25,6 +25,8 @@ function scene.sceneInit()
BG.set("none") BG.set("none")
end end
-- command_help_messages format: -- command_help_messages format:
-- command_help_messages is a table -- command_help_messages is a table
-- key: the command -- key: the command
@@ -56,7 +58,7 @@ local command_help_messages={
"print() can be used to print text into this window." "print() can be used to print text into this window."
} }
}, },
["exit"]={ exit={
description="Return to the previous menu.", description="Return to the previous menu.",
details={ details={
"Return to the previous menu.", "Return to the previous menu.",
@@ -206,11 +208,11 @@ local command_help_list={
local command_help_page_size=10 local command_help_page_size=10
local commands={ local commands={}
--Basic commands --Basic commands
help=function(arg) function commands.help(arg)
if command_help_messages[arg]then -- help [command] if command_help_messages[arg]then -- help [command]
for i,v in pairs(command_help_messages[arg]["details"]) do for _,v in pairs(command_help_messages[arg].details)do
log(v) log(v)
end end
return return
@@ -225,24 +227,24 @@ local commands={
log("Invalid page number. Must be between 1 and "..total_pages.." (inclusive).") log("Invalid page number. Must be between 1 and "..total_pages.." (inclusive).")
return return
end end
log("Use help [page] to view more commands,") log"Use help [page] to view more commands,"
log("or help [command_name] for more info on a command.") log"or help [command_name] for more info on a command."
log("") log""
log("Page "..arg.." of "..total_pages) log("Page "..arg.." of "..total_pages)
for i=(arg-1)*10+1,math.min(arg*10,#command_help_list)do for i=(arg-1)*10+1,math.min(arg*10,#command_help_list)do
local _c=command_help_list[i] local _c=command_help_list[i]
log("".._c.." - "..command_help_messages[_c]["description"]) log("".._c.." - "..command_help_messages[_c].description)
end end
end, end
shutdown=function(arg)os.execute("shutdown "..arg)end, function commands.shutdown(arg)os.execute("shutdown "..arg)end
cls=function()outputBox:clear()end, function commands.cls()outputBox:clear()end
echo=log, commands.echo=log
exit=backScene, commands.exit=backScene
quit=backScene, commands.quit=backScene
bye=backScene, commands.bye=backScene
--Game commands --Game commands
fn=function(n) function commands.fn(n)
if tonumber(n)then if tonumber(n)then
n=int(tonumber(n)) n=int(tonumber(n))
if n>=1 and n<=12 then if n>=1 and n<=12 then
@@ -251,34 +253,34 @@ local commands={
end end
end end
log"Usage: fn [1~12]" log"Usage: fn [1~12]"
end, end
scrinfo=function()for _,v in next,SCR.info()do log(v)end end, function commands.scrinfo()for _,v in next,SCR.info()do log(v)end end
wireframe=function(bool) function commands.wireframe(bool)
if bool=="true"or bool=="false"then if bool=="true"or bool=="false"then
gc.setWireframe(bool=="true") gc.setWireframe(bool=="true")
log("Wireframe: "..(gc.isWireframe()and"on"or"off")) log("Wireframe: "..(gc.isWireframe()and"on"or"off"))
else else
log"Usage: wireframe [true|false]" log"Usage: wireframe [true|false]"
end end
end, end
gammacorrect=function(bool) function commands.gammacorrect(bool)
if bool=="true"or bool=="false"then if bool=="true"or bool=="false"then
love._setGammaCorrect(bool=="true") love._setGammaCorrect(bool=="true")
log("GammaCorrect: "..(gc.isGammaCorrect()and"on"or"off")) log("GammaCorrect: "..(gc.isGammaCorrect()and"on"or"off"))
else else
log"Usage: gammacorrect [true|false]" log"Usage: gammacorrect [true|false]"
end end
end, end
rmwtm=function(password) function commands.rmwtm(password)
if password=="196022"then if password==(14^2*10)..(2*11)then
_G["\100\114\97\119\70\87\77"]=NULL _G["\100\114\97\119\70\87\77"]=NULL
log("\68\69\86\58\87\97\116\101\114\109\97\114\107\32\82\101\109\111\118\101\100") log("\68\69\86\58\87\97\116\101\114\109\97\114\107\32\82\101\109\111\118\101\100")
SFX.play("clear") SFX.play("clear")
else else
log"Usage: None." log"Usage: None."
end end
end, end
unlockall=function(bool) function commands.unlockall(bool)
if bool=="sure"then if bool=="sure"then
for name,M in next,MODES do for name,M in next,MODES do
if type(name)=="string"and not RANKS[name]and M.x then if type(name)=="string"and not RANKS[name]and M.x then
@@ -292,8 +294,8 @@ local commands={
log"Are you sure to unlock all modes?" log"Are you sure to unlock all modes?"
log"Type: unlockall sure" log"Type: unlockall sure"
end end
end, end
play=function(m)--marathon_bfmax can only played here function commands.play(m)--marathon_bfmax can only played here
if MODES[m]then if MODES[m]then
loadGame(m) loadGame(m)
elseif m then elseif m then
@@ -301,8 +303,10 @@ local commands={
else else
log"Usage: play [modeName]" log"Usage: play [modeName]"
end end
end, end
}
function scene.keyDown(k) function scene.keyDown(k)
if k=="return"then if k=="return"then
local input=inputBox.value local input=inputBox.value