add some type checking, ???
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
--essentially a really chunky layer to make SetScore elegant(ish)
|
--essentially a really chunky layer to make SetScore elegant(ish)
|
||||||
--arguments for scorekeepers: JudgmentMessageCommand,PlayerStageStats,PlayerNumber,State
|
--arguments for scorekeepers: JudgmentMessageCommand,PlayerStageStats,PlayerNumber,State
|
||||||
--[[changelog
|
--[[changelog
|
||||||
|
v1.42 21 May 2012
|
||||||
|
*Add more type checking.
|
||||||
|
*Don't crash on missing modes.
|
||||||
v1.41 6 May 2012
|
v1.41 6 May 2012
|
||||||
*Not really sure.
|
*Not really sure.
|
||||||
*Included in SM5 for alpha 3.
|
*Included in SM5 for alpha 3.
|
||||||
@@ -27,6 +30,8 @@ function GetNumReadiedScoreKeepers()
|
|||||||
return table.itemcount(ReadiedScoreKeepers)
|
return table.itemcount(ReadiedScoreKeepers)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--InitScoreKeepers(string p1Mode, string p2Mode)
|
||||||
|
--Both are optional.
|
||||||
function InitScoreKeepers(p1Mode, p2Mode)
|
function InitScoreKeepers(p1Mode, p2Mode)
|
||||||
local newStgK = {pcall(GameState.GetStageSeed,GAMESTATE)}
|
local newStgK = {pcall(GameState.GetStageSeed,GAMESTATE)}
|
||||||
assert(newStgK[1], "it's too early to initialize the ScoreKeepers, the GameState isn't ready yet")
|
assert(newStgK[1], "it's too early to initialize the ScoreKeepers, the GameState isn't ready yet")
|
||||||
@@ -34,6 +39,12 @@ function InitScoreKeepers(p1Mode, p2Mode)
|
|||||||
Log "[InitScoreKeepers] unnecessary call"
|
Log "[InitScoreKeepers] unnecessary call"
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
if p1Mode~=nil then
|
||||||
|
assert(type(p1Mode)=="string", "only pass string or nil")
|
||||||
|
end
|
||||||
|
if p2Mode~=nil then
|
||||||
|
assert(type(p2Mode)=="string", "only pass string or nil")
|
||||||
|
end
|
||||||
ReadiedScoreKeepers={}
|
ReadiedScoreKeepers={}
|
||||||
JudgmentFilters={}
|
JudgmentFilters={}
|
||||||
stageKey = newStgK
|
stageKey = newStgK
|
||||||
@@ -47,9 +58,7 @@ function InitScoreKeepers(p1Mode, p2Mode)
|
|||||||
assert(next(intab), "InitScoreKeepers didn't get any args")
|
assert(next(intab), "InitScoreKeepers didn't get any args")
|
||||||
for k,v in pairs(intab) do
|
for k,v in pairs(intab) do
|
||||||
if not ScoringModes[v] then
|
if not ScoringModes[v] then
|
||||||
--SPOILER: UndocumentedFeature crashes the game intentionally.
|
Warn(k.."'s scoring mode \""..v.."\" doesn't exist.")
|
||||||
-- UndocumentedFeature(k.."'s scoring mode \""..v.."\" doesn't exist.")
|
|
||||||
-- UndocumentedFeature(k.."'s scoring mode doesn't exist.")
|
|
||||||
else
|
else
|
||||||
ReadiedScoreKeepers[k] = coroutine.create(ScoringModes[v])
|
ReadiedScoreKeepers[k] = coroutine.create(ScoringModes[v])
|
||||||
--call each scoring mode one time in init mode
|
--call each scoring mode one time in init mode
|
||||||
|
|||||||
Reference in New Issue
Block a user