From 1cf89233a89b7c18d74bc50f03f94cf2cb164efb Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 15 Dec 2006 23:03:47 +0000 Subject: [PATCH] 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 --- stepmania/Themes/default/Scripts/ActorDef.lua | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/stepmania/Themes/default/Scripts/ActorDef.lua b/stepmania/Themes/default/Scripts/ActorDef.lua index 51c85ab055..86b6f011bd 100644 --- a/stepmania/Themes/default/Scripts/ActorDef.lua +++ b/stepmania/Themes/default/Scripts/ActorDef.lua @@ -83,10 +83,12 @@ local function ResolvePath( path, level ) end -- Load an actor template. -function LoadActor( path ) - local ResolvedPath = ResolvePath( path, 2 ); +function LoadActorFunc( path, level ) + level = level or 1 + + local ResolvedPath = ResolvePath( path, level+1 ); if not ResolvedPath then - error( path .. ": not found", 2 ); + error( path .. ": not found", level+1 ); end path = ResolvedPath @@ -103,21 +105,21 @@ function LoadActor( path ) if Type == "FileType_Bitmap" or Type == "FileType_Movie" then return function() return Def.Sprite { - _Level = 1, + _Level = level+1, Texture = path } end elseif Type == "FileType_Sound" then return function() return Def.Sound { - _Level = 1, + _Level = level+1, File = path } end elseif Type == "FileType_Model" then return function() return Def.Model { - _Level = 1, + _Level = level+1, Meshes = path, Materials = path, Bones = path @@ -126,13 +128,20 @@ function LoadActor( path ) elseif Type == "FileType_Directory" then return function() return Def.BGAnimation { - _Level = 1, + _Level = level+1, AniDir = path, } 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 -- (c) 2006 Glenn Maynard