Script Help

Chrusion

gold plated 3D
mdoyle,

Would you care to see what I'm doing wrong with this Lingo script?

Code:
-- the goal for this script is that after all the motions are "cropped", that
-- the 3D sprite will just go ahead and loop play this segment of the animation
-- after the script ends.  Not unless something more needs to be done.

on beginSprite me
  
  pMember = sprite(me.spriteNum).member  -- reference the cast member of this sprite
  
  mCount = pMember.motion.count -- get how many motions are in the model
  
  -- cycle thru all motions, set their play range to loop the last
  -- 3.33 seconds at the end of the animation
  repeat while mCount > 1
    motionName = pMember.motion(mCount).name  -- get the name of the motion
    
    -- this is where the object (I assume it's the keyframeplayer) isn't found
    -- and failing the script.
    pMember.model(mCount).keyframePlayer.play(motionName, 1, 50333, 53333, 1)
    
    mCount = mCount - 1
  end repeat
  
end

The more interesting thing is that the script below that I wrote works just fine. I simply copy/pasted to the above and modified some variable names.

Code:
property  pMember
global playTime, scrub  -- these obviously arrive from other scripts

on beginSprite me
  pMember = sprite(me.spriteNum).member
end


on exitFrame me
  mScrub
end

on mScrub me
  motions = pMember.model.count
  if scrub then
    repeat while motions > 1
      pMember.model(motions).keyframePlayer.currentTime = playTime
      motions = motions - 1
    end repeat
  end if
end

Anyway, thanks.
 

Chrusion

gold plated 3D
I discovered why the code above was failing.

The motion object indexed by the value of the variable motions, which is actually the number of models in the w3d file, was not matching the model. That is, if the model count = 25, the motion for this model is actually index 26. Thus the following code works now.

Code:
    -- Cycle thru all models and set their motion channels to loop play the last
    -- 3.33 seconds of their animations.

    repeat with i = 1 to mCount
      pMotion = pMember.motion(i + 1).name
      pModel = pMember.model(i).name
      pMember.model(pModel).keyframePlayer.play(pMotion, bLoop, sTime * 1000, eTime * 1000, 1)
    end repeat
 
Last edited:

mdoyle

New member
Am glad you got it worked out. I haven't checked the newtek forums in over a month, with christmas and work, it was a bit busy.
 
Top Bottom