整理代码(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")
end
-- command_help_messages format:
-- command_help_messages is a table
-- key: the command
@@ -56,7 +58,7 @@ local command_help_messages={
"print() can be used to print text into this window."
}
},
["exit"]={
exit={
description="Return to the previous menu.",
details={
"Return to the previous menu.",
@@ -206,11 +208,11 @@ local command_help_list={
local command_help_page_size=10
local commands={
local commands={}
--Basic commands
help=function(arg)
function commands.help(arg)
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)
end
return
@@ -225,24 +227,24 @@ local commands={
log("Invalid page number. Must be between 1 and "..total_pages.." (inclusive).")
return
end
log("Use help [page] to view more commands,")
log("or help [command_name] for more info on a command.")
log("")
log"Use help [page] to view more commands,"
log"or help [command_name] for more info on a command."
log""
log("Page "..arg.." of "..total_pages)
for i=(arg-1)*10+1,math.min(arg*10,#command_help_list)do
local _c=command_help_list[i]
log("".._c.." - "..command_help_messages[_c]["description"])
log("".._c.." - "..command_help_messages[_c].description)
end
end,
shutdown=function(arg)os.execute("shutdown "..arg)end,
cls=function()outputBox:clear()end,
echo=log,
exit=backScene,
quit=backScene,
bye=backScene,
end
function commands.shutdown(arg)os.execute("shutdown "..arg)end
function commands.cls()outputBox:clear()end
commands.echo=log
commands.exit=backScene
commands.quit=backScene
commands.bye=backScene
--Game commands
fn=function(n)
function commands.fn(n)
if tonumber(n)then
n=int(tonumber(n))
if n>=1 and n<=12 then
@@ -251,34 +253,34 @@ local commands={
end
end
log"Usage: fn [1~12]"
end,
scrinfo=function()for _,v in next,SCR.info()do log(v)end end,
wireframe=function(bool)
end
function commands.scrinfo()for _,v in next,SCR.info()do log(v)end end
function commands.wireframe(bool)
if bool=="true"or bool=="false"then
gc.setWireframe(bool=="true")
log("Wireframe: "..(gc.isWireframe()and"on"or"off"))
else
log"Usage: wireframe [true|false]"
end
end,
gammacorrect=function(bool)
end
function commands.gammacorrect(bool)
if bool=="true"or bool=="false"then
love._setGammaCorrect(bool=="true")
log("GammaCorrect: "..(gc.isGammaCorrect()and"on"or"off"))
else
log"Usage: gammacorrect [true|false]"
end
end,
rmwtm=function(password)
if password=="196022"then
end
function commands.rmwtm(password)
if password==(14^2*10)..(2*11)then
_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")
SFX.play("clear")
else
log"Usage: None."
end
end,
unlockall=function(bool)
end
function commands.unlockall(bool)
if bool=="sure"then
for name,M in next,MODES do
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"Type: unlockall sure"
end
end,
play=function(m)--marathon_bfmax can only played here
end
function commands.play(m)--marathon_bfmax can only played here
if MODES[m]then
loadGame(m)
elseif m then
@@ -301,8 +303,10 @@ local commands={
else
log"Usage: play [modeName]"
end
end,
}
end
function scene.keyDown(k)
if k=="return"then
local input=inputBox.value