rename LoadActor to LoadActorFunc
allow level param to LoadActorFunc LoadActor now evaluates the function; arguments can be passed directly to LoadActor; use LoadActorFunc if you want to get the factory directly
This commit is contained in:
@@ -83,10 +83,12 @@ local function ResolvePath( path, level )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Load an actor template.
|
-- Load an actor template.
|
||||||
function LoadActor( path )
|
function LoadActorFunc( path, level )
|
||||||
local ResolvedPath = ResolvePath( path, 2 );
|
level = level or 1
|
||||||
|
|
||||||
|
local ResolvedPath = ResolvePath( path, level+1 );
|
||||||
if not ResolvedPath then
|
if not ResolvedPath then
|
||||||
error( path .. ": not found", 2 );
|
error( path .. ": not found", level+1 );
|
||||||
end
|
end
|
||||||
path = ResolvedPath
|
path = ResolvedPath
|
||||||
|
|
||||||
@@ -103,21 +105,21 @@ function LoadActor( path )
|
|||||||
if Type == "FileType_Bitmap" or Type == "FileType_Movie" then
|
if Type == "FileType_Bitmap" or Type == "FileType_Movie" then
|
||||||
return function()
|
return function()
|
||||||
return Def.Sprite {
|
return Def.Sprite {
|
||||||
_Level = 1,
|
_Level = level+1,
|
||||||
Texture = path
|
Texture = path
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
elseif Type == "FileType_Sound" then
|
elseif Type == "FileType_Sound" then
|
||||||
return function()
|
return function()
|
||||||
return Def.Sound {
|
return Def.Sound {
|
||||||
_Level = 1,
|
_Level = level+1,
|
||||||
File = path
|
File = path
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
elseif Type == "FileType_Model" then
|
elseif Type == "FileType_Model" then
|
||||||
return function()
|
return function()
|
||||||
return Def.Model {
|
return Def.Model {
|
||||||
_Level = 1,
|
_Level = level+1,
|
||||||
Meshes = path,
|
Meshes = path,
|
||||||
Materials = path,
|
Materials = path,
|
||||||
Bones = path
|
Bones = path
|
||||||
@@ -126,13 +128,20 @@ function LoadActor( path )
|
|||||||
elseif Type == "FileType_Directory" then
|
elseif Type == "FileType_Directory" then
|
||||||
return function()
|
return function()
|
||||||
return Def.BGAnimation {
|
return Def.BGAnimation {
|
||||||
_Level = 1,
|
_Level = level+1,
|
||||||
AniDir = path,
|
AniDir = path,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
error( path .. ": unknown file type (" .. tostring(Type) .. ")", 2 );
|
error( path .. ": unknown file type (" .. tostring(Type) .. ")", level+1 );
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Load and create an actor template.
|
||||||
|
function LoadActor( path, ... )
|
||||||
|
local t = LoadActorFunc( path, 2 );
|
||||||
|
assert(t);
|
||||||
|
return t(...);
|
||||||
end
|
end
|
||||||
|
|
||||||
-- (c) 2006 Glenn Maynard
|
-- (c) 2006 Glenn Maynard
|
||||||
|
|||||||
Reference in New Issue
Block a user