整理序列生成器代码
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
local ins,rem=table.insert,table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
local yield=coroutine.yield
|
local yield=coroutine.yield
|
||||||
|
|
||||||
local sequenceModes={
|
local seqGens={
|
||||||
none=function() while true do yield()end end,
|
none=function() while true do yield()end end,
|
||||||
bag=function(P,seq0)
|
bag=function(P,seq0)
|
||||||
local len=#seq0
|
local len=#seq0
|
||||||
@@ -139,22 +139,18 @@ local sequenceModes={
|
|||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
return function(P)--Set newNext funtion for player P
|
return function(P)--Set newNext funtion for player P
|
||||||
local ENV=P.gameEnv
|
local s=P.gameEnv.sequence
|
||||||
::tryAgain::
|
if type(s)=="function"then
|
||||||
if type(ENV.sequence)=="string"then
|
return s
|
||||||
if sequenceModes[ENV.sequence]then
|
elseif type(s)=="string"and seqGens[s]then
|
||||||
P.newNext=coroutine.create(sequenceModes[ENV.sequence])
|
return seqGens[s]
|
||||||
else
|
|
||||||
LOG.print("No sequence mode called "..ENV.sequence,"warn")
|
|
||||||
ENV.sequence="bag"
|
|
||||||
goto tryAgain
|
|
||||||
end
|
|
||||||
elseif type(ENV.sequence)=="function"then
|
|
||||||
P.newNext=coroutine.create(ENV.sequence)
|
|
||||||
else
|
else
|
||||||
LOG.print("Wrong sequence generator","warn")
|
LOG.print(
|
||||||
ENV.sequence="bag"
|
type(s)=="string"and
|
||||||
goto tryAgain
|
"No sequence mode called "..s or
|
||||||
|
"Wrong sequence generator",
|
||||||
|
"warn")
|
||||||
|
P.gameEnv.sequence="bag"
|
||||||
|
return seqGens.bag
|
||||||
end
|
end
|
||||||
assert(coroutine.resume(P.newNext,P,ENV.seqData))
|
|
||||||
end
|
end
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
local Player=require"parts.player.player"
|
local Player=require"parts.player.player"
|
||||||
local sequenceGenerator=require"parts.player.sequenceGenerator"
|
local getSeqGen=require"parts.player.getSeqGen"
|
||||||
local gameEnv0=require"parts.player.gameEnv0"
|
local gameEnv0=require"parts.player.gameEnv0"
|
||||||
|
|
||||||
local rnd,max=math.random,math.max
|
local rnd,max=math.random,math.max
|
||||||
@@ -307,7 +307,9 @@ local function applyGameEnv(P)--Finish gameEnv processing
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ENV.nextCount==0 then ENV.nextPos=false end
|
if ENV.nextCount==0 then ENV.nextPos=false end
|
||||||
sequenceGenerator(P)
|
|
||||||
|
P.newNext=coroutine.create(getSeqGen(P))
|
||||||
|
assert(coroutine.resume(P.newNext,P,P.gameEnv.seqData))
|
||||||
|
|
||||||
if P.mini then
|
if P.mini then
|
||||||
ENV.lockFX=false
|
ENV.lockFX=false
|
||||||
|
|||||||
Reference in New Issue
Block a user