Change "modSystem" to "modApplyAt"
This commit is contained in:
@@ -334,7 +334,7 @@ do-- function DATA.saveReplay()
|
||||
seed=GAME.seed,
|
||||
setting=GAME.setting,
|
||||
mod=_getModList(),
|
||||
modPatch=GAME.modPatch,
|
||||
modApplyAt=GAME.modApplyAt,
|
||||
tasUsed=GAME.tasUsed,
|
||||
}
|
||||
if GAME.curMode.savePrivate then
|
||||
@@ -394,7 +394,7 @@ function DATA.parseReplayData(fileName,fileData,ifFull)
|
||||
seed=metaData.seed,
|
||||
setting=metaData.setting,
|
||||
mod=metaData.mod,
|
||||
modPatch=metaData.modPatch,
|
||||
modApplyAt=metaData.modApplyAt,
|
||||
tasUsed=metaData.tasUsed,
|
||||
}
|
||||
if ifFull then rep.data=fileData end
|
||||
|
||||
@@ -388,7 +388,7 @@ do-- Mod data
|
||||
{no=6,id="HD",name="hidden",
|
||||
key="i",x=920,y=230,color='lP',
|
||||
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",
|
||||
key="o",x=1040,y=230,color='lP',
|
||||
@@ -400,7 +400,6 @@ do-- Mod data
|
||||
key="p",x=1160,y=230,color='lJ',
|
||||
list={'U-D','L-R','180'},
|
||||
func=function(P,O) P.gameEnv.flipBoard=O end,
|
||||
onlyOnce=true,
|
||||
},
|
||||
|
||||
{no=9,id="DT",name="dropDelay",
|
||||
@@ -431,17 +430,14 @@ do-- Mod data
|
||||
key="j",x=860,y=350,color='lY',
|
||||
list={0,1,2,3,5,10,15,26,42,87,500},
|
||||
func=function(P,O) P.gameEnv.life=O end,
|
||||
onlyOnce=true,
|
||||
},
|
||||
{no=14,id="FB",name="forceB2B",
|
||||
key="k",x=980,y=350,color='lY',
|
||||
func=function(P) P.gameEnv.b2bKill=true end,
|
||||
onlyOnce=true,
|
||||
},
|
||||
{no=15,id="PF",name="forceFinesse",
|
||||
key="l",x=1100,y=350,color='lY',
|
||||
func=function(P) P.gameEnv.fineKill=true end,
|
||||
onlyOnce=true,
|
||||
},
|
||||
|
||||
{no=16,id="TL",name="tele",
|
||||
@@ -458,7 +454,6 @@ do-- Mod data
|
||||
_disableKey(P,4)
|
||||
_disableKey(P,5)
|
||||
end,
|
||||
onlyOnce=true,
|
||||
},
|
||||
{no=18,id="GL",name="noMove",
|
||||
key="c",x=440,y=470,color='lH',
|
||||
@@ -468,13 +463,11 @@ do-- Mod data
|
||||
_disableKey(P,17)_disableKey(P,18)
|
||||
_disableKey(P,19)_disableKey(P,20)
|
||||
end,
|
||||
onlyOnce=true,
|
||||
},
|
||||
{no=19,id="CS",name="customSeq",
|
||||
key="b",x=680,y=470,color='lB',
|
||||
list={'bag','bagES','his','hisPool','c2','bagP1inf','rnd','mess','reverb'},
|
||||
func=function(P,O) P.gameEnv.sequence=O end,
|
||||
onlyOnce=true,
|
||||
},
|
||||
{no=20,id="PS",name="pushSpeed",
|
||||
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
|
||||
end
|
||||
end,
|
||||
executeFirst=true
|
||||
},
|
||||
}
|
||||
for i=1,#MODOPT do
|
||||
@@ -522,7 +514,7 @@ do-- Game data tables
|
||||
curMode=false, -- Current gamemode object
|
||||
initPlayerCount=0, -- Player count when init game
|
||||
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
|
||||
setting={}, -- Game settings
|
||||
rep={}, -- Recording list, key,time,key,time...
|
||||
|
||||
@@ -175,6 +175,17 @@ local function _newEmptyPlayer(id,mini)
|
||||
}
|
||||
return P
|
||||
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
|
||||
P.gameEnv={}-- Current game setting environment
|
||||
local ENV=P.gameEnv
|
||||
@@ -199,39 +210,21 @@ local function _loadGameEnv(P)-- Load gameEnv
|
||||
ENV[k]=TABLE.copy(v)
|
||||
end
|
||||
end
|
||||
if ENV.allowMod then
|
||||
if GAME.modPatch then
|
||||
if not GAME.modCodeList then GAME.modCodeList={} end
|
||||
if not GAME.modCodeList[P.id] then GAME.modCodeList[P.id]={} end
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
-- if not GAME.modCodeList then GAME.modCodeList={} end
|
||||
-- if not GAME.modCodeList[P.id] then GAME.modCodeList[P.id]={} end
|
||||
-- if ENV.allowMod then
|
||||
-- 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
|
||||
local function _loadRemoteEnv(P,confStr)-- Load gameEnv
|
||||
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))
|
||||
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.dropDelay=ENV.drop
|
||||
@@ -364,10 +379,14 @@ local function _applyGameEnv(P)-- Finish gameEnv processing
|
||||
ENV.nextPos=false
|
||||
end
|
||||
|
||||
local seqGen=coroutine.create(getSeqGen(ENV.sequence))
|
||||
local seqCalled=false
|
||||
local initSZOcount=0
|
||||
local bagLineCounter=0
|
||||
local seqGen,seqCalled,initSZOcount,bagLineCounter
|
||||
function P:resetSeqGen()
|
||||
seqGen=coroutine.create(getSeqGen(ENV.sequence))
|
||||
seqCalled=false
|
||||
initSZOcount=0
|
||||
bagLineCounter=0
|
||||
end
|
||||
P:resetSeqGen()
|
||||
function P:newNext()
|
||||
local status,piece
|
||||
if seqCalled then
|
||||
|
||||
Reference in New Issue
Block a user