From 0ec4356901ce6ddf9efddae1329f8aed5f44b3ff Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 6 Feb 2007 02:59:48 +0000 Subject: [PATCH] Allow Lua concatenated tables to concatenate functions. This means that code loading an actor can have an InitCommand even if the actor itself also has an InitCommand. The actor's own InitCommand will be run first, followed by the caller's. --- stepmania/Themes/default/Scripts/ActorDef.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/stepmania/Themes/default/Scripts/ActorDef.lua b/stepmania/Themes/default/Scripts/ActorDef.lua index 20a220f4f2..ff4b465eda 100644 --- a/stepmania/Themes/default/Scripts/ActorDef.lua +++ b/stepmania/Themes/default/Scripts/ActorDef.lua @@ -17,8 +17,15 @@ local function MergeTables( left, right ) for key, val in pairs(right) do if ret[key] then - Warn( string.format( "%s\n\nOverriding \"%s\"", - debug.traceback(), key) ); + if type(val) == "function" and + type(ret[key]) == "function" then + local f1 = ret[key]; + local f2 = val + val = function(...) f1(...); return f2(...) end + else + Warn( string.format( "%s\n\nOverriding \"%s\"", + debug.traceback(), key) ); + end end ret[key] = val;