@@ -4,7 +4,9 @@ local ins,rem=table.insert,table.remove
44local outputBox = WIDGET .new {type = ' textBox' ,x = 20 ,y = 20 ,w = 999 ,h = 999 ,fontSize = 25 ,fontType = ' _mono' ,lineHeight = 25 ,fixContent = true }
55local inputBox = WIDGET .new {type = ' inputBox' ,x = 20 ,y = 999 ,w = 999 ,h = 80 ,fontType = ' _mono' }
66
7+ -- Console Log
78local function log (str ) outputBox :push (str ) end
9+ _CL = log
810
911log {COLOR .lP ," Zenitha Console" }
1012log {COLOR .lC ," © Copyright 2019–2023 26F Studio. Some rights reserved." }
@@ -46,11 +48,12 @@ local commands={} do
4648 for i = 1 ,# cmdList do
4749 local cmd = cmdList [i ]
4850 local body = commands [cmd ]
51+ local color = body .builtin and COLOR .L or COLOR .lR
4952 log (
5053 body .description and
51- {COLOR . L ,cmd ,COLOR .LD ,STRING .repD (" $1 $2" ,(" ·" ):rep (16 -# cmd ),body .description )}
54+ {color ,cmd ,COLOR .LD ,STRING .repD (" $1 $2" ,(" ·" ):rep (16 -# cmd ),body .description )}
5255 or
53- log { COLOR . L ,cmd }
56+ { color ,cmd }
5457 )
5558 end
5659 end
@@ -552,7 +555,6 @@ local commands={} do
552555 log {COLOR .Y ," * Now you should use the _CL(message) function to print into this console *" }
553556 log {COLOR .Y ," * 最高权限模式开启, 请不要执行任何自己不懂确切含义的代码 *" }
554557 log {COLOR .Y ," * 从现在开始请使用_CL(信息)函数在控制台打印信息 *" }
555- _CL = log
556558 else
557559 log {COLOR .Y ," Password incorrect" }
558560 end
@@ -561,7 +563,9 @@ local commands={} do
561563
562564 for cmd ,body in next ,commands do
563565 if type (body )== ' function' then
564- commands [cmd ]= {code = body }
566+ commands [cmd ]= {code = body ,builtin = true }
567+ elseif type (body )== ' table' then
568+ body .builtin = true
565569 end
566570 if type (body )~= ' string' then
567571 ins (cmdList ,cmd )
@@ -572,7 +576,7 @@ local commands={} do
572576
573577 --- Add custom console command
574578 --- @param name string
575- --- @param cmd function |{ code : fun ( str : string ), description : string , details : string[] }
579+ --- @param cmd function |{ code : fun ( str : string ), description : string , details : string[] , builtin : nil }
576580 function ZENITHA .addConsoleCommand (name ,cmd )
577581 assert (type (name )== ' string' ," CMD name need string" )
578582 assert (not commands [name ]," CMD already exists" )
@@ -581,6 +585,7 @@ local commands={} do
581585 assert (type (cmd .code )== ' function' ," CMD.code need function" )
582586 assert (cmd .description == nil or type (cmd .description )== ' string' ," CMD.description need string if exists" )
583587 assert (cmd .details == nil or type (cmd .details )== ' table' ," CMD.details need table if exists" )
588+ assert (cmd .builtin == nil ," ?" )
584589 commands [name ]= cmd
585590 ins (cmdList ,name )
586591 table.sort (cmdList )
0 commit comments