From 55562324e208c0e2e43b334b1230c0b294ee7648 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Fri, 20 Oct 2017 19:45:47 -0600 Subject: [PATCH] Fix relative paths in simfiles. (#1512) --- Themes/_fallback/Scripts/02 ActorDef.lua | 27 +++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Themes/_fallback/Scripts/02 ActorDef.lua b/Themes/_fallback/Scripts/02 ActorDef.lua index 13fb5c0394..d940bb03da 100644 --- a/Themes/_fallback/Scripts/02 ActorDef.lua +++ b/Themes/_fallback/Scripts/02 ActorDef.lua @@ -62,16 +62,27 @@ setmetatable( Def, { if t._Level then level = t._Level + 1 end - local info = debug.getinfo(level,"Sl"); + local info - -- Source file of caller: - local Source = info.source - t._Source = Source + -- Sometimes info.source will be "=(tail call)" when we need the actual + -- file something came from. + -- So this loop climbs the stack until it reaches an actual file path + -- or reaches end. + repeat + info = debug.getinfo(level,"Sl"); + if info then + -- Source file of caller: + local source= info.source + t._Source= source + -- Line number of caller: + t._Line = info.currentline + t._Dir= DebugPathToRealPath(source) - t._Dir = DebugPathToRealPath( Source ) - - -- Line number of caller: - t._Line = info.currentline + -- level is incremented for the next time through the loop. Take + -- that into account if level is used after the loop. + level= level + 1 + end + until t._Dir or not info setmetatable( t, DefMetatable ) return t