split out ActorUtil::LoadXNodeFromStackShowErrors
This commit is contained in:
+38
-12
@@ -252,31 +252,57 @@ namespace
|
||||
Lua *L = LUA->Get();
|
||||
|
||||
RString sError;
|
||||
if( !LuaHelpers::RunScript(L, sScript, "@" + sFile, sError, 0, 1) )
|
||||
if( !LuaHelpers::LoadScript(L, sScript, "@" + sFile, sError) )
|
||||
{
|
||||
lua_pop( L, 1 );
|
||||
LUA->Release( L );
|
||||
sError = ssprintf( "Lua runtime error: %s", sError.c_str() );
|
||||
Dialog::OK( sError, "LUA_ERROR" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( lua_type(L, -1) != LUA_TTABLE )
|
||||
{
|
||||
lua_pop( L, 1 );
|
||||
LUA->Release( L );
|
||||
sError = ssprintf( "%s: must return a table", sFile.c_str() );
|
||||
Dialog::OK( sError, "LUA_ERROR" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XNode *pRet = XmlFileUtil::XNodeFromTable( L );
|
||||
XNode *pRet = ActorUtil::LoadXNodeFromStackShowErrors( L );
|
||||
|
||||
LUA->Release( L );
|
||||
return pRet;
|
||||
}
|
||||
}
|
||||
|
||||
XNode *ActorUtil::LoadXNodeFromStackShowErrors( Lua *L )
|
||||
{
|
||||
LuaReference func;
|
||||
lua_pushvalue( L, -1 );
|
||||
func.SetFromStack( L );
|
||||
|
||||
RString sError;
|
||||
if( !LuaHelpers::RunScriptOnStack(L, sError, 0, 1) )
|
||||
{
|
||||
lua_pop( L, 1 );
|
||||
LUA->Release( L );
|
||||
sError = ssprintf( "Lua runtime error: %s", sError.c_str() );
|
||||
Dialog::OK( sError, "LUA_ERROR" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( lua_type(L, -1) != LUA_TTABLE )
|
||||
{
|
||||
lua_pop( L, 1 );
|
||||
|
||||
func.PushSelf( L );
|
||||
lua_Debug debug;
|
||||
lua_getinfo( L, ">nS", &debug );
|
||||
|
||||
sError = ssprintf( "%s: must return a table", debug.short_src );
|
||||
LUA->Release( L );
|
||||
|
||||
Dialog::OK( sError, "LUA_ERROR" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XNode *pRet = XmlFileUtil::XNodeFromTable( L );
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/*
|
||||
* If pParent is non-NULL, it's the parent node when nesting XML, which is
|
||||
* used only by ActorUtil::LoadFromNode.
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace ActorUtil
|
||||
RString GetSourcePath( const XNode *pNode );
|
||||
RString GetWhere( const XNode *pNode );
|
||||
bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut );
|
||||
XNode *LoadXNodeFromStackShowErrors( Lua *L );
|
||||
|
||||
bool ResolvePath( RString &sPath, const RString &sName );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user