任务系统完成,支持导入导出,修复错误(之前的anyN有问题)

This commit is contained in:
MrZ626
2020-09-19 00:02:58 +08:00
parent 0c648a8c1e
commit 754d9a2afc
5 changed files with 74 additions and 47 deletions

View File

@@ -169,6 +169,37 @@ function pasteSequence(str)
return true
end
function copyTarget()
local str=""
local preMission=preMission
for i=1,#preMission do
str=str..char(preMission[i])
end
return data.encode("string","base64",data.compress("string","deflate",str))
end
function pasteTarget(str)
local _
--Decode
_,str=pcall(data.decode,"string","base64",str)
if not _ then return end
_,str=pcall(data.decompress,"string","deflate",str)
if not _ then return end
local mission={}
for i=1,#str do
_=byte(str,i)
if missionEnum[_]then
ins(mission,_)
else
return
end
end
preMission=mission
return true
end
function mergeStat(stat,delta)
for k,v in next,delta do
if type(v)=="table"then

View File

@@ -163,6 +163,22 @@ for i=1,8 do
end
end
missionEnum={
_1=01,_2=02,_3=03,_4=04,
Z1=11,Z2=12,Z3=13,
S1=21,S2=22,S3=23,
J1=31,J2=32,J3=33,
L1=41,L2=42,L3=43,
T1=51,T2=52,T3=53,
O1=61,O2=62,O3=63,O4=64,
I1=71,I2=72,I3=73,I4=74,
A1=91,A2=92,A3=93,A4=94,
PC=99,
}
for k,v in next,missionEnum do
missionEnum[v]=k
end
local function T(s,t)return love.graphics.newText(setFont(s),t)end
drawableText={
question=T(100,"?"),right=T(45,""),

View File

@@ -2420,11 +2420,11 @@ do--player.drop(P)--Place piece
success=true
end
elseif t<90 then
if C.row==int(t/10)and C.name==t%10 then
if C.row==t%10 and C.name==int(t/10)then
success=true
end
elseif t<99 then
if C.row==int(t/10)then
if C.row==t%10 then
success=true
end
elseif t==99 then
@@ -2434,6 +2434,7 @@ do--player.drop(P)--Place piece
end
if success then
P.missionProgress=P.missionProgress+1
SFX.play("reach")
if P.missionProgress==#P.gameEnv.mission then
P:win()
end

View File

@@ -1592,28 +1592,7 @@ do--custom_mission
}
end
local clear={
Z1=11,Z2=21,Z3=31,
S1=12,S2=22,S3=32,
J1=13,J2=23,J3=33,
L1=14,L2=24,L3=34,
T1=15,T2=25,T3=35,
O1=16,O2=26,O3=36,O4=46,
I1=17,I2=27,I3=37,I4=47,
A1=91,A2=92,A3=93,A4=94,
_1=01,_2=02,_3=03,_4=04,
PC=99,
[11]="Z1",[21]="Z2",[31]="Z3",
[12]="S1",[22]="S2",[32]="S3",
[13]="J1",[23]="J2",[33]="J3",
[14]="L1",[24]="L2",[34]="L3",
[15]="T1",[25]="T2",[35]="T3",
[16]="O1",[26]="O2",[36]="O3",[46]="O4",
[17]="I1",[27]="I2",[37]="I3",[47]="I4",
[91]="A1",[92]="A2",[93]="A3",[94]="A4",
[01]="_1",[02]="_2",[03]="_3",[04]="_4",
[99]="PC",
}
local missionEnum=missionEnum
local legalInput={Z=true,S=true,J=true,L=true,T=true,O=true,I=true,A=true,_=true,P=true}
function keyDown.custom_mission(key)
local S=sceneTemp
@@ -1675,9 +1654,9 @@ do--custom_mission
local input=S.input
input=input..key
if clear[input]then
if missionEnum[input]then
input=""
ins(preMission,clear[input])
ins(preMission,missionEnum[input])
elseif #input>1 or not legalInput[input]then
input=""
end
@@ -1712,7 +1691,7 @@ do--custom_mission
local x,y=100,136--Next block pos
local cx,cy=100,136--Cursor-center pos
for i=1,#preMission do
gc.print(clear[preMission[i]],x,y-25)
gc.print(missionEnum[preMission[i]],x,y-25)
x=x+55
if x>1160 then
x,y=100,y+50