It's a layerscript, so it's embedded in a switch layer. Not run from any actions.
After digging deeper, it's oddly specific. It doesn't always happen and seems to be tied specifically to being placed inside bone layers. This is the structure that definitely triggers it:
Code: Select all
Bone Layer
> Switch Layer (with script embedded)
> Bone Layer (with Smart Bone actions)
> Switch Layer (that script targets)
> Bone Layer (with Smart Bone actions)
> Switch Layer (that script targets)
In that layer structure, the timelines for the smart bone actions on those bone layers end up being keyed too. Given that it's more specific and confusing than I first thought, it likely has more to do with how I find the target folders.
I have the full script below. As I said it's based on someone else's script, I just added the ability to target multiple slave layers and to target layers that are nested deeper in folders. So it recursively searches through all the folders adjacent to the master layer (the switch with the script embedded in it) and will add keys to any switch slave layer it finds. It's possible that somehow the recursion is finding the other timeline, but I'm unclear how that would happen and how to avoid it.
Code: Select all
function LayerScript(moho)
-- ************************************************************
-- SlaveSwitch (c)2005 B. Quinn
-- Updates (c)2016 G. Chadwick
--
-- Can now deal with slaves being nested in folders.
-- And can operate on multiple slaves.
--
-- V 3.0
-- ************************************************************
local frame = moho.frame
local layer = moho:LayerAsSwitch(moho.layer)
if layer == nil then return end
local target = layer:Name() .. ".sslv"
local layers = {}
local layerCount = 0
local function searchAllChildren(currentLayer, moho, layerCount, layers)
for count = 0, currentLayer:CountLayers() - 1 do
local testLayer = currentLayer:Layer(count)
-- return if it matches target
if (testLayer:Name() == target) then
layers[layerCount] = moho:LayerAsSwitch(testLayer)
layerCount = layerCount + 1
else
testLayer = moho:LayerAsGroup(testLayer)
if (testLayer ~= nil and testLayer:CountLayers() > 0) then
layerCount, layers = searchAllChildren(testLayer, moho, layerCount, layers)
end
end
end
return layerCount, layers
end
local parent = layer:Parent()
local currentLayerGroup
if (parent == nil) then
currentLayerGroup = moho.document
else
currentLayerGroup = moho:LayerAsGroup(parent)
end
layerCount, layers = searchAllChildren(currentLayerGroup, moho, layerCount, layers)
--These make sure to adjust the value of a keyframe if it exists and if none exists make sure to not create one.
for i, switch in pairs(layers) do
if layer:SwitchValues():HasKey(frame) then
local switchName = layer:SwitchValues():GetValue(frame)
switch:SwitchValues():SetValue(frame, switchName)
else
switch:SwitchValues():DeleteKey(frame)
end
end
end