Change "modSystem" to "modApplyAt"
This commit is contained in:
@@ -334,7 +334,7 @@ do-- function DATA.saveReplay()
|
|||||||
seed=GAME.seed,
|
seed=GAME.seed,
|
||||||
setting=GAME.setting,
|
setting=GAME.setting,
|
||||||
mod=_getModList(),
|
mod=_getModList(),
|
||||||
modPatch=GAME.modPatch,
|
modApplyAt=GAME.modApplyAt,
|
||||||
tasUsed=GAME.tasUsed,
|
tasUsed=GAME.tasUsed,
|
||||||
}
|
}
|
||||||
if GAME.curMode.savePrivate then
|
if GAME.curMode.savePrivate then
|
||||||
@@ -394,7 +394,7 @@ function DATA.parseReplayData(fileName,fileData,ifFull)
|
|||||||
seed=metaData.seed,
|
seed=metaData.seed,
|
||||||
setting=metaData.setting,
|
setting=metaData.setting,
|
||||||
mod=metaData.mod,
|
mod=metaData.mod,
|
||||||
modPatch=metaData.modPatch,
|
modApplyAt=metaData.modApplyAt,
|
||||||
tasUsed=metaData.tasUsed,
|
tasUsed=metaData.tasUsed,
|
||||||
}
|
}
|
||||||
if ifFull then rep.data=fileData end
|
if ifFull then rep.data=fileData end
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ do-- Mod data
|
|||||||
{no=6,id="HD",name="hidden",
|
{no=6,id="HD",name="hidden",
|
||||||
key="i",x=920,y=230,color='lP',
|
key="i",x=920,y=230,color='lP',
|
||||||
list={'easy','slow','medium','fast','none'},
|
list={'easy','slow','medium','fast','none'},
|
||||||
func=function(P,O) P.gameEnv.visible=O end, -- TODO
|
func=function(P,O) P.gameEnv.visible=O end,
|
||||||
},
|
},
|
||||||
{no=7,id="HB",name="hideBoard",
|
{no=7,id="HB",name="hideBoard",
|
||||||
key="o",x=1040,y=230,color='lP',
|
key="o",x=1040,y=230,color='lP',
|
||||||
@@ -400,7 +400,6 @@ do-- Mod data
|
|||||||
key="p",x=1160,y=230,color='lJ',
|
key="p",x=1160,y=230,color='lJ',
|
||||||
list={'U-D','L-R','180'},
|
list={'U-D','L-R','180'},
|
||||||
func=function(P,O) P.gameEnv.flipBoard=O end,
|
func=function(P,O) P.gameEnv.flipBoard=O end,
|
||||||
onlyOnce=true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{no=9,id="DT",name="dropDelay",
|
{no=9,id="DT",name="dropDelay",
|
||||||
@@ -431,17 +430,14 @@ do-- Mod data
|
|||||||
key="j",x=860,y=350,color='lY',
|
key="j",x=860,y=350,color='lY',
|
||||||
list={0,1,2,3,5,10,15,26,42,87,500},
|
list={0,1,2,3,5,10,15,26,42,87,500},
|
||||||
func=function(P,O) P.gameEnv.life=O end,
|
func=function(P,O) P.gameEnv.life=O end,
|
||||||
onlyOnce=true,
|
|
||||||
},
|
},
|
||||||
{no=14,id="FB",name="forceB2B",
|
{no=14,id="FB",name="forceB2B",
|
||||||
key="k",x=980,y=350,color='lY',
|
key="k",x=980,y=350,color='lY',
|
||||||
func=function(P) P.gameEnv.b2bKill=true end,
|
func=function(P) P.gameEnv.b2bKill=true end,
|
||||||
onlyOnce=true,
|
|
||||||
},
|
},
|
||||||
{no=15,id="PF",name="forceFinesse",
|
{no=15,id="PF",name="forceFinesse",
|
||||||
key="l",x=1100,y=350,color='lY',
|
key="l",x=1100,y=350,color='lY',
|
||||||
func=function(P) P.gameEnv.fineKill=true end,
|
func=function(P) P.gameEnv.fineKill=true end,
|
||||||
onlyOnce=true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{no=16,id="TL",name="tele",
|
{no=16,id="TL",name="tele",
|
||||||
@@ -458,7 +454,6 @@ do-- Mod data
|
|||||||
_disableKey(P,4)
|
_disableKey(P,4)
|
||||||
_disableKey(P,5)
|
_disableKey(P,5)
|
||||||
end,
|
end,
|
||||||
onlyOnce=true,
|
|
||||||
},
|
},
|
||||||
{no=18,id="GL",name="noMove",
|
{no=18,id="GL",name="noMove",
|
||||||
key="c",x=440,y=470,color='lH',
|
key="c",x=440,y=470,color='lH',
|
||||||
@@ -468,13 +463,11 @@ do-- Mod data
|
|||||||
_disableKey(P,17)_disableKey(P,18)
|
_disableKey(P,17)_disableKey(P,18)
|
||||||
_disableKey(P,19)_disableKey(P,20)
|
_disableKey(P,19)_disableKey(P,20)
|
||||||
end,
|
end,
|
||||||
onlyOnce=true,
|
|
||||||
},
|
},
|
||||||
{no=19,id="CS",name="customSeq",
|
{no=19,id="CS",name="customSeq",
|
||||||
key="b",x=680,y=470,color='lB',
|
key="b",x=680,y=470,color='lB',
|
||||||
list={'bag','bagES','his','hisPool','c2','bagP1inf','rnd','mess','reverb'},
|
list={'bag','bagES','his','hisPool','c2','bagP1inf','rnd','mess','reverb'},
|
||||||
func=function(P,O) P.gameEnv.sequence=O end,
|
func=function(P,O) P.gameEnv.sequence=O end,
|
||||||
onlyOnce=true,
|
|
||||||
},
|
},
|
||||||
{no=20,id="PS",name="pushSpeed",
|
{no=20,id="PS",name="pushSpeed",
|
||||||
key="n",x=800,y=470,color='lB',
|
key="n",x=800,y=470,color='lB',
|
||||||
@@ -491,7 +484,6 @@ do-- Mod data
|
|||||||
for _,bk in pairs(P.nextQueue) do bk.color=17 end
|
for _,bk in pairs(P.nextQueue) do bk.color=17 end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
executeFirst=true
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for i=1,#MODOPT do
|
for i=1,#MODOPT do
|
||||||
@@ -522,7 +514,7 @@ do-- Game data tables
|
|||||||
curMode=false, -- Current gamemode object
|
curMode=false, -- Current gamemode object
|
||||||
initPlayerCount=0, -- Player count when init game
|
initPlayerCount=0, -- Player count when init game
|
||||||
mod=TABLE.new(0,#MODOPT),-- List of loaded mods
|
mod=TABLE.new(0,#MODOPT),-- List of loaded mods
|
||||||
modPatch=false, -- Mods can lock value to prevent changes? False by default to compactible with old replays (from 0.17 to 0.17.15)
|
modApplyAt='preInit', -- Apply mod when? (preInit, postInit, always)
|
||||||
modeEnv=false, -- Current gamemode environment
|
modeEnv=false, -- Current gamemode environment
|
||||||
setting={}, -- Game settings
|
setting={}, -- Game settings
|
||||||
rep={}, -- Recording list, key,time,key,time...
|
rep={}, -- Recording list, key,time,key,time...
|
||||||
|
|||||||
@@ -175,6 +175,17 @@ local function _newEmptyPlayer(id,mini)
|
|||||||
}
|
}
|
||||||
return P
|
return P
|
||||||
end
|
end
|
||||||
|
local function _executeMod(P)
|
||||||
|
local applyStatus=GAME.modApplyAt
|
||||||
|
for i=1,#GAME.mod do
|
||||||
|
if GAME.mod[i]>0 then
|
||||||
|
local M=MODOPT[i]
|
||||||
|
if applyStatus~='always' or M.noAlwaysNeeded then
|
||||||
|
M.func(P,M.list and M.list[GAME.mod[i]])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
local function _loadGameEnv(P)-- Load gameEnv
|
local function _loadGameEnv(P)-- Load gameEnv
|
||||||
P.gameEnv={}-- Current game setting environment
|
P.gameEnv={}-- Current game setting environment
|
||||||
local ENV=P.gameEnv
|
local ENV=P.gameEnv
|
||||||
@@ -199,39 +210,21 @@ local function _loadGameEnv(P)-- Load gameEnv
|
|||||||
ENV[k]=TABLE.copy(v)
|
ENV[k]=TABLE.copy(v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if ENV.allowMod then
|
|
||||||
if GAME.modPatch then
|
-- if not GAME.modCodeList then GAME.modCodeList={} end
|
||||||
if not GAME.modCodeList then GAME.modCodeList={} end
|
-- if not GAME.modCodeList[P.id] then GAME.modCodeList[P.id]={} end
|
||||||
if not GAME.modCodeList[P.id] then GAME.modCodeList[P.id]={} end
|
-- if ENV.allowMod then
|
||||||
if not GAME.ApplyModsTask then
|
-- for i=1,#GAME.mod do
|
||||||
GAME.ApplyModsTask=function()
|
-- if GAME.mod[i]>0 then
|
||||||
while GAME.playing do
|
-- local M=MODOPT[i]
|
||||||
for _,p in pairs(GAME.modCodeList) do
|
-- if not GAME.modPatch or M.executeFirst or M.onlyOnce then
|
||||||
for _,c in pairs(p) do pcall(c) end
|
-- M.func(P,M.list and M.list[GAME.mod[i]])
|
||||||
end
|
-- elseif GAME.modPatch and not M.onlyOnce then
|
||||||
coroutine.yield()
|
-- table.insert(GAME.modCodeList[P.id],function() M.func(P,M.list and M.list[GAME.mod[i]],true) end)
|
||||||
end
|
-- end
|
||||||
-- Kill mod patching function when game stopped
|
-- end
|
||||||
TASK.removeTask_code(GAME.ApplyModsTask)
|
-- end
|
||||||
TABLE.cut(GAME.modCodeList)
|
-- end
|
||||||
GAME.modCodeList=nil
|
|
||||||
GAME.ApplyModsTask=nil
|
|
||||||
end
|
|
||||||
TASK.new(GAME.ApplyModsTask)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
for i=1,#GAME.mod do
|
|
||||||
if GAME.mod[i]>0 then
|
|
||||||
local M=MODOPT[i]
|
|
||||||
if not GAME.modPatch or M.executeFirst or M.onlyOnce then
|
|
||||||
M.func(P,M.list and M.list[GAME.mod[i]])
|
|
||||||
elseif GAME.modPatch and not M.onlyOnce then
|
|
||||||
table.insert(GAME.modCodeList[P.id],function() M.func(P,M.list and M.list[GAME.mod[i]],true) end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local function _loadRemoteEnv(P,confStr)-- Load gameEnv
|
local function _loadRemoteEnv(P,confStr)-- Load gameEnv
|
||||||
confStr=JSON.decode(confStr)
|
confStr=JSON.decode(confStr)
|
||||||
@@ -315,6 +308,28 @@ local function _applyGameEnv(P)-- Finish gameEnv processing
|
|||||||
MES.new('warn',"Wrong event set type: "..type(ENV.eventSet))
|
MES.new('warn',"Wrong event set type: "..type(ENV.eventSet))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- if GAME.modPatch then
|
||||||
|
-- if not GAME.ApplyModsTask then
|
||||||
|
-- GAME.ApplyModsTask=function()
|
||||||
|
-- while GAME.playing do
|
||||||
|
-- for _,p in pairs(GAME.modCodeList) do
|
||||||
|
-- for _,c in pairs(p) do pcall(c) end
|
||||||
|
-- end
|
||||||
|
-- coroutine.yield()
|
||||||
|
-- end
|
||||||
|
-- -- Kill mod patching function when game stopped
|
||||||
|
-- TASK.removeTask_code(GAME.ApplyModsTask)
|
||||||
|
-- TABLE.cut(GAME.modCodeList)
|
||||||
|
-- GAME.modCodeList=nil
|
||||||
|
-- GAME.ApplyModsTask=nil
|
||||||
|
-- end
|
||||||
|
-- TASK.new(GAME.ApplyModsTask)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
if ENV.allowMod and GAME.modApplyAt=='postInit' then
|
||||||
|
_executeMod(P)
|
||||||
|
end
|
||||||
|
|
||||||
P._20G=ENV.drop==0
|
P._20G=ENV.drop==0
|
||||||
P.dropDelay=ENV.drop
|
P.dropDelay=ENV.drop
|
||||||
@@ -364,10 +379,14 @@ local function _applyGameEnv(P)-- Finish gameEnv processing
|
|||||||
ENV.nextPos=false
|
ENV.nextPos=false
|
||||||
end
|
end
|
||||||
|
|
||||||
local seqGen=coroutine.create(getSeqGen(ENV.sequence))
|
local seqGen,seqCalled,initSZOcount,bagLineCounter
|
||||||
local seqCalled=false
|
function P:resetSeqGen()
|
||||||
local initSZOcount=0
|
seqGen=coroutine.create(getSeqGen(ENV.sequence))
|
||||||
local bagLineCounter=0
|
seqCalled=false
|
||||||
|
initSZOcount=0
|
||||||
|
bagLineCounter=0
|
||||||
|
end
|
||||||
|
P:resetSeqGen()
|
||||||
function P:newNext()
|
function P:newNext()
|
||||||
local status,piece
|
local status,piece
|
||||||
if seqCalled then
|
if seqCalled then
|
||||||
|
|||||||
Reference in New Issue
Block a user