From a99014b64be59c6e8e99c537c42e7127c5422956 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Tue, 29 Dec 2020 23:29:49 +0800 Subject: [PATCH] =?UTF-8?q?quest=E5=8C=85=E5=90=AB=E5=A4=9A=E5=9C=BA?= =?UTF-8?q?=E5=9C=B0=EF=BC=8C=E5=8E=9F=E6=A0=BC=E5=BC=8F=E5=A4=B1=E6=95=88?= =?UTF-8?q?=EF=BC=88=E5=8F=AF=E6=89=8B=E5=8A=A8=E4=BF=AE=E5=A4=8D=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=B2=98=E8=B4=B4quest=E5=90=8E?= =?UTF-8?q?=E5=B7=A6=E4=B8=8B=E5=B0=8F=E5=9C=BA=E5=9C=B0=E7=94=BB=E9=9D=A2?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/gametoolfunc.lua | 12 +++++++- parts/scenes/customGame.lua | 60 ++++++++++++++----------------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index eb34d6ca..951d36b8 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -81,6 +81,7 @@ function copyQuestArgs() return str end function pasteQuestArgs(str) + if #str<4 then return end local ENV=CUSTOMENV ENV.holdCount= byte(str,1)-48 ENV.ospin= byte(str,2)~=90 @@ -184,8 +185,17 @@ function copyBoard(page)--Copy the [page] board end return data.encode("string","base64",data.compress("string","zlib",str)) end +function copyBoards() + local out={} + for i=1,#FIELD do + out[i]=copyBoard(i) + end + return table.concat(out,"!") +end function pasteBoard(str,page)--Paste [str] data to [page] board - local F=FIELD[page or 1] + if not page then page=1 end + if not FIELD[page]then FIELD[page]=newBoard()end + local F=FIELD[page] local _,__ --Decode diff --git a/parts/scenes/customGame.lua b/parts/scenes/customGame.lua index 2f0f396e..05ca48a4 100644 --- a/parts/scenes/customGame.lua +++ b/parts/scenes/customGame.lua @@ -2,31 +2,32 @@ local gc,sys=love.graphics,love.system local kb=love.keyboard local int=math.floor -local find,sub=string.find,string.sub local function notAir(L) for i=1,10 do if L[i]>0 then return true end end end - local CUSTOMENV=CUSTOMENV local scene={} local initField - -function scene.sceneInit() - destroyPlayers() - BG.set(CUSTOMENV.bg) - BGM.play(CUSTOMENV.bgm) +local function freshMiniFieldVisible() initField=false for y=1,20 do if notAir(FIELD[1][y])then initField=true + return end end end +function scene.sceneInit() + destroyPlayers() + BG.set(CUSTOMENV.bg) + BGM.play(CUSTOMENV.bgm) + freshMiniFieldVisible() +end function scene.sceneBack() BGM.play() end @@ -63,41 +64,26 @@ function scene.keyDown(key) elseif key=="c"and kb.isDown("lctrl","rctrl")or key=="cC"then local str="Techmino Quest:"..copyQuestArgs().."!" if #BAG>0 then str=str..copySequence()end - str=str.."!"..copyBoard().."!" + str=str.."!" if #MISSION>0 then str=str..copyMission()end - sys.setClipboardText(str.."!") + sys.setClipboardText(str.."!"..copyBoards().."!") LOG.print(text.exportSuccess,COLOR.green) elseif key=="v"and kb.isDown("lctrl","rctrl")or key=="cV"then local str=sys.getClipboardText() - local p1,p2,p3,p4,p5--ptr* - while true do - p1=find(str,":")or 0 - p2=find(str,"!",p1+1) - if not p2 then break end - p3=find(str,"!",p2+1) - if not p3 then break end - p4=find(str,"!",p3+1) - if not p4 then break end - p5=find(str,"!",p4+1)or #str+1 - - pasteQuestArgs(sub(str,p1+1,p2-1)) - if p2+1~=p3 then - if not pasteSequence(sub(str,p2+1,p3-1))then - break - end - end - if not pasteBoard(sub(str,p3+1,p4-1))then - break - end - if p4+1~=p5 then - if not pasteMission(sub(str,p4+1,p5-1))then - break - end - end - LOG.print(text.importSuccess,COLOR.green) - return + local args=splitStr(str:sub((str:find(":")or 0)+1),"!") + if #args<4 then goto fail end + if not pasteQuestArgs(args[1])then goto fail end + if not pasteSequence(args[2])then goto fail end + if not pasteMission(args[3])then goto fail end + repeat table.remove(FIELD)until #FIELD==0 + FIELD[1]=newBoard() + for i=4,#args do + if not pasteBoard(args[i],i-3)and i<#args then goto fail end end - LOG.print(text.dataCorrupted,COLOR.red) + freshMiniFieldVisible() + LOG.print(text.importSuccess,COLOR.green) + do return end + ::fail::LOG.print(text.dataCorrupted,COLOR.red) elseif key=="escape"then SCN.back() else