

Code: Select all
if (moho.layer:CurrentAction() ~= "") then
return
end

Moderators: Víctor Paredes, Belgarath, slowtiger
Code: Select all
if (moho.layer:CurrentAction() ~= "") then
return
end
THANK YOU!Rasheed wrote:Ramón, it could just be that people didn't respond because they were awed by your audacity to take on scripting.
Code: Select all
function LayerScript(moho)
local frame = moho.frame
if (moho.frame ~= 0) then
local switchName = moho.layer:SwitchValues():GetValue(frame)
moho.layer:SwitchValues():SetValue(0, switchName)
end
end
Code: Select all
function LayerScript(moho)
local mesh
local i
local mesh = moho:Mesh()
if ( mesh ~= nil ) then
local pointCount = mesh:CountPoints()
for i = 0, pointCount-1 do
local point = mesh:Point( i )
point.fAnimPos:GetValue(frame)
end
end
end
Code: Select all
point.fAnimPos:GetValue(frame)
Code: Select all
local mesh
local i
Code: Select all
print ("point #:", i, "x:", point.x, "y:", point.y)
Ramón López wrote: [...] Well, as you know (I think...), I have always wished the possibility to can change the way Moho treat Bones/Points interaction during animation works, you know, to can change between: bones deform points based on 0 frame points position or bones deform points based on current frame points position...
The case is that I really need something like this to can obtain the desired results and I've been treating to write an Embedded Script that copy current (cursor time) points position to frame 0 in real time, I mean, the script would transmit all the fAnimPos/fPos or AnimVec2 (I'm not sure yet...) info of the current frame to frame 0, all to can get frame 0 points position be always exactly the same that the position of that points in any other current frame... so bones be "deceived" and well, can "simulate" with it that the bone forces over the points change "dynamicaly" in time...
Of course, I know... all this seems like a madness, isn't? Well, but (if possible) that is precisely that I want to know before waste more time in the "scripting" works... Do you think that, if finally I could get the script works, something like this could work propertly? Or in the other hand (and as I afraid...) could result in a mess, bugged and unexpected animation results? [...]
And... :D LM wrote: [...] I think what you describe would be possible, but there is also one big problem.
First, to change the position at frame zero, you would do something like this:
The skeleton would then work on the new point position. There is a slight problem: I'm not sure about the sequence of events. The skeleton might get applied before your script gets called. In that case, the skeleton wouldn't use the new value you set - it wouldn't know about it until the next frame. So, the skeleton might be running kind of "one frame behind".Code: Select all
local pt = mesh:Point(id) -- the next line copies the current position back to frame 0 pt:SetPos(pt.fAnimPos:GetValue(currentFrame), 0)
The bigger problem is that you're over-writing the point positions at frame 0. So, when you do go back to frame zero, the points will be moved around in strange ways. To fix this, your script would need to save the original frame 0 positions, and restore them if the user ever went back to the real frame 0. This would take some work, but it seems like it could be possible.
Code: Select all
function LayerScript(moho)
local frame = moho.frame
local mesh = moho:Mesh ()
local pointCount = mesh:CountPoints ()
if (mesh:CountPoints () < 1) or (moho.frame == 0) then
return
end
-------------------------------------------------------------
for i = 0, pointCount-1 do
local mPoint = mesh:Point (i)
pt = mPoint
end
pt:SetPos(pt.fAnimPos:GetValue(frame), 0)
end
Code: Select all
for i = 0, pointCount-1 do
local mPoint = mesh:Point (i)
pt = mPoint
end
Code: Select all
while (mesh:CountPoints () > 1) or (moho.frame < 0) do
Code: Select all
function LayerScript(moho)
local frame = moho.frame
local mesh = moho:Mesh ()
local pointCount = mesh:CountPoints ()
if (mesh:CountPoints () < 1) or (moho.frame == 0) then
return
end
-------------------------------------------------------------
for i = 0, pointCount-1 do
local mPoint = mesh:Point (i)
pt = mPoint
pt:SetPos(pt.fAnimPos:GetValue(frame), 0)
end
end