Lineage reporting for nil commands in RunCommands. Stricter type checking for FormatPercentScore in PercentageDisplay.

This commit is contained in:
Kyzentun
2014-10-28 20:32:38 -06:00
parent 034790849d
commit 5639a0d31f
4 changed files with 34 additions and 19 deletions
+2 -2
View File
@@ -706,7 +706,7 @@ PercentUseRemainder=false
ApplyScoreDisplayOptions=true
DancePointsDigits=5
#
Format="%2d"
Format=FormatPercentScore
#
RemainderFormat=
#
@@ -1399,7 +1399,7 @@ DancePointsDigits=1
PercentUseRemainder=true
ApplyScoreDisplayOptions=false
FormatPercentScore=FormatPercentScore
Format=
Format=FormatPercentScore
[SoundEffectControl]
LockToHold=false
-2
View File
@@ -140,8 +140,6 @@ NumLivesP2OnCommand=zoomx,-1
NumLivesP2LoseLifeCommand=zoomx,-1.5;zoomy,1.5;linear,0.15;zoomx,-1;zoomy,1
[LifeMeterBattery Percent]
# still asking for this even though it's in fallback... -aj
Format=
#
PercentP2OnCommand=zoom,0.7;zoomx,-0.7;shadowlength,0;diffuse,PlayerColor(PLAYER_2)
DancePointsP2OnCommand=zoom,0.7;zoomx,-0.7;shadowlength,0;diffuse,PlayerColor(PLAYER_2)
+4 -4
View File
@@ -785,7 +785,7 @@ RString Actor::GetLineage() const
if( m_pParent )
sPath = m_pParent->GetLineage() + '/';
sPath += ssprintf( "<%s> %s", typeid(*this).name(), m_sName.c_str() );
sPath += ssprintf( "<type %s> %s", typeid(*this).name(), m_sName.c_str() );
return sPath;
}
@@ -1130,7 +1130,7 @@ void Actor::RunCommands( const LuaReference& cmds, const LuaReference *pParamTab
{
if( !cmds.IsSet() || cmds.IsNil() )
{
LuaHelpers::ReportScriptError("RunCommands: command is unset or nil");
LuaHelpers::ReportScriptErrorFmt("RunCommands: commands for %s are unset or nil", GetLineage().c_str());
return;
}
@@ -1140,7 +1140,7 @@ void Actor::RunCommands( const LuaReference& cmds, const LuaReference *pParamTab
cmds.PushSelf( L );
if( lua_isnil(L, -1) )
{
LuaHelpers::ReportScriptError("Error compiling commands");
LuaHelpers::ReportScriptErrorFmt("RunCommands: Error compiling commands for %s", GetLineage().c_str());
LUA->Release(L);
return;
}
@@ -1155,7 +1155,7 @@ void Actor::RunCommands( const LuaReference& cmds, const LuaReference *pParamTab
pParamTable->PushSelf( L );
// call function with 2 arguments and 0 results
RString Error= "Error playing command: ";
RString Error= "Error playing command:";
LuaHelpers::RunScriptOnStack(L, Error, 2, 0, true);
LUA->Release(L);
+28 -11
View File
@@ -33,10 +33,22 @@ void PercentageDisplay::LoadFromNode( const XNode* pNode )
pNode->GetAttrValue( "AutoRefresh", m_bAutoRefresh );
{
Lua *L = LUA->Get();
if( pNode->PushAttrValue(L, "FormatPercentScore") )
if(pNode->PushAttrValue(L, "FormatPercentScore"))
{
m_FormatPercentScore.SetFromStack( L );
if(m_FormatPercentScore.GetLuaType() != LUA_TFUNCTION)
{
// Not reported as an error because _fallback and default provided bad
// examples in their [LifeMeterBattery Percent]:Format metric and nobody
// realized it was supposed to be set to a function. -Kyz
LOG->Trace("Format attribute for PercentageDisplay named '%s' is not a function. Defaulting to 'FormatPercentScore'.", GetName().c_str());
m_FormatPercentScore.SetFromExpression("FormatPercentScore");
}
}
else
{
lua_pop(L, 1);
}
LUA->Release(L);
}
@@ -86,9 +98,12 @@ void PercentageDisplay::Load( const PlayerState *pPlayerState, const PlayerStage
m_sPercentFormat = THEME->GetMetric( sMetricsGroup, "PercentFormat" );
m_sRemainderFormat = THEME->GetMetric( sMetricsGroup, "RemainderFormat" );
if( m_FormatPercentScore.IsNil() )
if(m_FormatPercentScore.GetLuaType() != LUA_TFUNCTION)
{
LOG->Trace( "Format is nil in [%s]. Defaulting to 'FormatPercentScore'.", sMetricsGroup.c_str() );
// Not reported as an error because _fallback and default provided bad
// examples in their [LifeMeterBattery Percent]:Format metric and nobody
// realized it was supposed to be set to a function. -Kyz
LOG->Trace("Format metric is not a function in [%s]. Defaulting to 'FormatPercentScore'.", sMetricsGroup.c_str());
m_FormatPercentScore.SetFromExpression( "FormatPercentScore" );
}
@@ -157,14 +172,16 @@ void PercentageDisplay::Refresh()
}
else
{
Lua *L = LUA->Get();
m_FormatPercentScore.PushSelf( L );
ASSERT( !lua_isnil(L, -1) );
LuaHelpers::Push( L, fPercentDancePoints );
RString Error= "Error running FormatPercentScore: ";
LuaHelpers::RunScriptOnStack(L, Error, 1, 1, true); // 1 arg, 1 result
LuaHelpers::Pop( L, sNumToDisplay );
LUA->Release(L);
if(m_FormatPercentScore.GetLuaType() == LUA_TFUNCTION)
{
Lua *L = LUA->Get();
m_FormatPercentScore.PushSelf( L );
LuaHelpers::Push( L, fPercentDancePoints );
RString Error= "Error running FormatPercentScore: ";
LuaHelpers::RunScriptOnStack(L, Error, 1, 1, true); // 1 arg, 1 result
LuaHelpers::Pop( L, sNumToDisplay );
LUA->Release(L);
}
// HACK: Use the last frame in the numbers texture as '-'
sNumToDisplay.Replace('-','x');