Notifications
Clear all

[Closed] scope inside a function and "at time…"

I have 1 dummy object moving 100 units in the direction of the Y axis in 100 frames.
So:

at time animationRange.start $Dummy01.pos.y
 0.0
 at time animationRange.end $Dummy01.pos.y
 100.0

At a frame rate of 100 fps, the position 1 frame ahead is:

at time (currentTime +1f) $Dummy01.pos.y
 0.0298

At a frame rate of 10 fps, the position 1 frame ahead is:

at time (currentTime +1f) $Dummy01.pos.y
 2.8

So far, so good.

Now my problem is this:


 fn posAhead frameR currentT obj = (
 	format "frameRateFromOutside: % frameRateInside: % currentTimeFromOutside: % currentTimeInside: % endRange: % pos: %
" frameRate frameT currentT currentTime animationRange.end (at time (currentT +1f) [b]obj[/b].pos.y)
 )

This function shows the position 1 frame ahead of obj.
With frameRate = 100fps:

posAhead frameRate currentTime [b]$Dummy01[/b]
frameRateFromOutside: 100 frameRateInside: 100 currentTimeFromOutside: 0f currentTimeInside: 0f endRange: 100f pos: [b]0.0298[/b]

Changing the frameRate to: 10fps

posAhead frameRate currentTime [b]$Dummy01[/b]
frameRateFromOutside: 10 frameRateInside: 10 currentTimeFromOutside: 0f currentTimeInside: 0f endRange: 10f pos: [b]0.0298[/b]

As you can see, frameRate and currentTime are updated, but not position of $Dummy01

Is there another way to update the value without re-defining the function?
thanks

3 Replies

there’s got to be a better way, but…


 fn posAhead frameR currentT obj = (
	 format "frameRateFromOutside: % frameRateInside: % currentTimeFromOutside: % currentTimeInside: % endRange: % pos: %
" frameRate frameT currentT currentTime animationRange.end (at time (currentT + (execute "1f")) obj.pos.y)
 )

works. The only thing I changed was ‘1f’ -> ‘(execute “1f”)’.

(btw, frameT is ‘undefined’; is that supposed to get passed to the function as well? Not relevant to the issue)

Hi ZeBoxx2, thank you!

So, “execute” is the only way to put time on time…
Make sense

well, at least if you want to keep that ‘1f’ within the function. You could feed it to the function explicitly;


fn posTOffset frameR currentT obj offset = (
	 format "frameRateFromOutside: % frameRateInside: % currentTimeFromOutside: % currentTimeInside: % endRange: % pos: %
" frameRate frameT currentT currentTime animationRange.end (at time (currentT + offset) (obj.pos.y) )
)
posTOffset frameRate currentTime $ 1f

That seems to work as well and gets rid of the nasty execute