Expose the optional argument for ResolvePath to lua and add it to ResolveRelativePath.
This commit is contained in:
@@ -472,8 +472,8 @@ save yourself some time, copy this for undocumented things:
|
|||||||
"Sets the real value of <code>t[index]</code> to <code>value</code>, without invoking any metamethod."
|
"Sets the real value of <code>t[index]</code> to <code>value</code>, without invoking any metamethod."
|
||||||
The modified <code>t</code> is then returned.
|
The modified <code>t</code> is then returned.
|
||||||
</Function>
|
</Function>
|
||||||
<Function name='ResolveRelativePath' theme='_fallback' return='string' arguments='string path, int level'>
|
<Function name='ResolveRelativePath' theme='_fallback' return='string' arguments='string path, int level, bool optional'>
|
||||||
[02 ActorDef.lua]
|
[02 ActorDef.lua] Used internally by LoadActor to resolve a path. If <code>optional</code> is true, then a nil path is returned instead of emitting an error if no file is found.
|
||||||
</Function>
|
</Function>
|
||||||
<Function name='ReadFile' theme='_fallback' return='string' arguments='string path'>
|
<Function name='ReadFile' theme='_fallback' return='string' arguments='string path'>
|
||||||
[04 FileUtils.lua] Reads the file at <code>path</code> and returns its contents.
|
[04 FileUtils.lua] Reads the file at <code>path</code> and returns its contents.
|
||||||
@@ -700,7 +700,9 @@ save yourself some time, copy this for undocumented things:
|
|||||||
<Function name='LoadAllCommandsAndSetXY' return='void' arguments='Actor a'>
|
<Function name='LoadAllCommandsAndSetXY' return='void' arguments='Actor a'>
|
||||||
Loads all commands and sets X and Y for the specified Actor.
|
Loads all commands and sets X and Y for the specified Actor.
|
||||||
</Function>
|
</Function>
|
||||||
<Function name='ResolvePath' return='string' arguments='string sPath, int iLevel' />
|
<Function name='ResolvePath' return='string' arguments='string sPath, int iLevel, bool optional'>
|
||||||
|
Used internally by LoadActor to resolve a path. If <code>optional</code> is true, then a nil path is returned instead of emitting an error if no file is found.
|
||||||
|
</Function>
|
||||||
</Namespace>
|
</Namespace>
|
||||||
<Namespace name='ArrowEffects'>
|
<Namespace name='ArrowEffects'>
|
||||||
<Function name='Update' return='void' arguments=''>
|
<Function name='Update' return='void' arguments=''>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ setmetatable( Def, {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
function ResolveRelativePath( path, level )
|
function ResolveRelativePath(path, level, optional)
|
||||||
if path:sub(1,1) ~= "/" then
|
if path:sub(1,1) ~= "/" then
|
||||||
-- "Working directory":
|
-- "Working directory":
|
||||||
local sDir = DebugPathToRealPath( debug.getinfo(level+1,"S").source )
|
local sDir = DebugPathToRealPath( debug.getinfo(level+1,"S").source )
|
||||||
@@ -88,7 +88,7 @@ function ResolveRelativePath( path, level )
|
|||||||
path = sDir .. path
|
path = sDir .. path
|
||||||
end
|
end
|
||||||
|
|
||||||
path = ActorUtil.ResolvePath( path, level+1 )
|
path = ActorUtil.ResolvePath(path, level+1, optional)
|
||||||
return path
|
return path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -623,13 +623,14 @@ namespace
|
|||||||
{
|
{
|
||||||
RString sPath( SArg(1) );
|
RString sPath( SArg(1) );
|
||||||
int iLevel = IArg(2);
|
int iLevel = IArg(2);
|
||||||
|
bool optional= lua_toboolean(L, 3);
|
||||||
luaL_where( L, iLevel );
|
luaL_where( L, iLevel );
|
||||||
RString sWhere = lua_tostring( L, -1 );
|
RString sWhere = lua_tostring( L, -1 );
|
||||||
if( sWhere.size() > 2 && sWhere.substr(sWhere.size()-2, 2) == ": " )
|
if( sWhere.size() > 2 && sWhere.substr(sWhere.size()-2, 2) == ": " )
|
||||||
sWhere = sWhere.substr( 0, sWhere.size()-2 ); // remove trailing ": "
|
sWhere = sWhere.substr( 0, sWhere.size()-2 ); // remove trailing ": "
|
||||||
|
|
||||||
LUA->YieldLua();
|
LUA->YieldLua();
|
||||||
bool bRet = ActorUtil::ResolvePath( sPath, sWhere );
|
bool bRet = ActorUtil::ResolvePath(sPath, sWhere, optional);
|
||||||
LUA->UnyieldLua();
|
LUA->UnyieldLua();
|
||||||
|
|
||||||
if( !bRet )
|
if( !bRet )
|
||||||
|
|||||||
Reference in New Issue
Block a user