From 2b3198b4dc5c194c414c48a894af4c01efaa2433 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 10 Sep 2020 01:00:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=95=B4=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=98=BE=E7=A4=BACC=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/ai.lua | 53 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/parts/ai.lua b/parts/ai.lua index 0514a933..d29291b7 100644 --- a/parts/ai.lua +++ b/parts/ai.lua @@ -16,34 +16,45 @@ local Timer=love.timer.getTime local blockPos={4,4,4,4,4,5,4} local scs={{0,1},{0,1},{0,1},{0,1},{0,1},{.5,.5},{-.5,1.5}} -------------------------------------------------Cold clear -local CCblockID={6,5,4,3,2,1,0} -CCloader_filename={ - Windows={"CCloader.dll",{"x86_64","x86"}}, - Android={"libCCloader.so",{"arm64-v8a","armeabi-v7a"}}, - Linux={"libCCloader.so",{"x86_64"}}, -} local function loadCC() - if not CCloader_filename[system]then return end - local f - for i=1,#CCloader_filename[system][2]do - function f() - local CCloader_f,size=love.filesystem.read("data",table.concat({"lib",system,CCloader_filename[system][2][i],CCloader_filename[system][1]},"/")) - if not CCloader_f then return end - local success,message=love.filesystem.write(CCloader_filename[system][1],CCloader_f,size) - if not success then return end - local success,message=package.loadlib(table.concat({love.filesystem.getSaveDirectory(),CCloader_filename[system][1]},"/"),"luaopen_CCloader") - return success,message + local SYS=({ + Windows={"CCloader.dll",{"x86_64","x86"}}, + Android={"libCCloader.so",{"arm64-v8a","armeabi-v7a"}}, + Linux={"libCCloader.so",{"x86_64"}}, + })[system] + if not SYS then return end + + local fs=love.filesystem + local libFunc,success,message + for i=1,#SYS[2]do + local CCloader_f,size=fs.read("data",table.concat({"lib",system,SYS[2][i],SYS[1]},"/")) + if CCloader_f then + LOG.print("Read CC-"..SYS[2][i].." successfully","warn",color.green) + success,message=fs.write(SYS[1],CCloader_f,size) + if success then + LOG.print("Write CC-"..SYS[2][i].." to saving successfully","warn",color.green) + libFunc,message=package.loadlib(table.concat({fs.getSaveDirectory(),SYS[1]},"/"),"luaopen_CCloader") + if libFunc then + LOG.print("CC lib loaded","warn",color.green) + break + else + LOG.print("Cannot load CC: "..message,"warn",color.red) + end + else + LOG.print("Write CC-"..SYS[2][i].." to saving failed","warn",color.red) + end + else + LOG.print("Read CC-"..SYS[2][i].." failed","warn",color.red) end - f=f() - if f then break end end - if not f then - CCloader_filename[system]=nil + if not libFunc then + SYS=nil LOG.print("failed to load CC","warn",color.red) return end LOG.print("CC load successfully","warn",color.green) - f() + libFunc() + local CCblockID={6,5,4,3,2,1,0} BOT={ getConf= cc.get_default_config ,--()options,weights --setConf= cc.set_options ,--(options,hold,20g,bag7)