diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml
index bf68845f0e..d6999e4873 100644
--- a/Docs/Luadoc/LuaDocumentation.xml
+++ b/Docs/Luadoc/LuaDocumentation.xml
@@ -472,8 +472,8 @@ save yourself some time, copy this for undocumented things:
"Sets the real value of t[index] to value, without invoking any metamethod."
The modified t is then returned.
-
- [02 ActorDef.lua]
+
+ [02 ActorDef.lua] Used internally by LoadActor to resolve a path. If optional is true, then a nil path is returned instead of emitting an error if no file is found.
[04 FileUtils.lua] Reads the file at path and returns its contents.
@@ -700,7 +700,9 @@ save yourself some time, copy this for undocumented things:
Loads all commands and sets X and Y for the specified Actor.
-
+
+ Used internally by LoadActor to resolve a path. If optional is true, then a nil path is returned instead of emitting an error if no file is found.
+
diff --git a/Themes/_fallback/Scripts/02 ActorDef.lua b/Themes/_fallback/Scripts/02 ActorDef.lua
index 2ce2f98b54..13fb5c0394 100644
--- a/Themes/_fallback/Scripts/02 ActorDef.lua
+++ b/Themes/_fallback/Scripts/02 ActorDef.lua
@@ -79,7 +79,7 @@ setmetatable( Def, {
end,
})
-function ResolveRelativePath( path, level )
+function ResolveRelativePath(path, level, optional)
if path:sub(1,1) ~= "/" then
-- "Working directory":
local sDir = DebugPathToRealPath( debug.getinfo(level+1,"S").source )
@@ -88,7 +88,7 @@ function ResolveRelativePath( path, level )
path = sDir .. path
end
- path = ActorUtil.ResolvePath( path, level+1 )
+ path = ActorUtil.ResolvePath(path, level+1, optional)
return path
end
diff --git a/src/ActorUtil.cpp b/src/ActorUtil.cpp
index d4435b7615..70c2aa891f 100644
--- a/src/ActorUtil.cpp
+++ b/src/ActorUtil.cpp
@@ -623,13 +623,14 @@ namespace
{
RString sPath( SArg(1) );
int iLevel = IArg(2);
+ bool optional= lua_toboolean(L, 3);
luaL_where( L, iLevel );
RString sWhere = lua_tostring( L, -1 );
if( sWhere.size() > 2 && sWhere.substr(sWhere.size()-2, 2) == ": " )
sWhere = sWhere.substr( 0, sWhere.size()-2 ); // remove trailing ": "
LUA->YieldLua();
- bool bRet = ActorUtil::ResolvePath( sPath, sWhere );
+ bool bRet = ActorUtil::ResolvePath(sPath, sWhere, optional);
LUA->UnyieldLua();
if( !bRet )