split out ActorUtil::LoadXNodeFromStackShowErrors
This commit is contained in:
@@ -252,7 +252,29 @@ namespace
|
|||||||
Lua *L = LUA->Get();
|
Lua *L = LUA->Get();
|
||||||
|
|
||||||
RString sError;
|
RString sError;
|
||||||
if( !LuaHelpers::RunScript(L, sScript, "@" + sFile, sError, 0, 1) )
|
if( !LuaHelpers::LoadScript(L, sScript, "@" + sFile, sError) )
|
||||||
|
{
|
||||||
|
LUA->Release( L );
|
||||||
|
sError = ssprintf( "Lua runtime error: %s", sError.c_str() );
|
||||||
|
Dialog::OK( sError, "LUA_ERROR" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
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_pop( L, 1 );
|
||||||
LUA->Release( L );
|
LUA->Release( L );
|
||||||
@@ -264,18 +286,22 @@ namespace
|
|||||||
if( lua_type(L, -1) != LUA_TTABLE )
|
if( lua_type(L, -1) != LUA_TTABLE )
|
||||||
{
|
{
|
||||||
lua_pop( L, 1 );
|
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 );
|
LUA->Release( L );
|
||||||
sError = ssprintf( "%s: must return a table", sFile.c_str() );
|
|
||||||
Dialog::OK( sError, "LUA_ERROR" );
|
Dialog::OK( sError, "LUA_ERROR" );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
XNode *pRet = XmlFileUtil::XNodeFromTable( L );
|
XNode *pRet = XmlFileUtil::XNodeFromTable( L );
|
||||||
|
|
||||||
LUA->Release( L );
|
|
||||||
return pRet;
|
return pRet;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If pParent is non-NULL, it's the parent node when nesting XML, which is
|
* If pParent is non-NULL, it's the parent node when nesting XML, which is
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ namespace ActorUtil
|
|||||||
RString GetSourcePath( const XNode *pNode );
|
RString GetSourcePath( const XNode *pNode );
|
||||||
RString GetWhere( const XNode *pNode );
|
RString GetWhere( const XNode *pNode );
|
||||||
bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut );
|
bool GetAttrPath( const XNode *pNode, const RString &sName, RString &sOut );
|
||||||
|
XNode *LoadXNodeFromStackShowErrors( Lua *L );
|
||||||
|
|
||||||
bool ResolvePath( RString &sPath, const RString &sName );
|
bool ResolvePath( RString &sPath, const RString &sName );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user