Inconsistent Code Behavior: Console vs. Menu

dpower
Posts: 2
Joined: Fri Jun 28, 2019 6:57 pm
Real name: David Power

Inconsistent Code Behavior: Console vs. Menu

#1

Post by dpower » Mon Jul 01, 2019 11:02 am

Hello, all.

When I type the following lines into the Fusion (Resolve 16b4) console window, it behaves as expected and creates keyframes at the desired locations:

Code: Select all

Lua> t = comp.ActiveTool
Lua> t.Center = Path()
Lua> t.Center[0] = {0.25, 0.5}
Lua> t.Center[24] = {0.75, 0.5}
When I use the same code in a .lua script, save it in ..\Fusion\Scripts\Tool, and launch it from the right-click menu in the Fusion Node view, I get the following error in the console:

Code: Select all

... Resolve\Support\Fusion\Scripts\Tool\DoD_Coordinates.lua:2: attempt to call global 'Path' (a nil value)
Any hints as to what I'm doing wrong?

Many thanks.

User avatar
Midgardsormr
Fusionator
Posts: 1020
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 1
Location: Los Angeles, CA, USA
Been thanked: 53 times
Contact:

Re: Inconsistent Code Behavior: Console vs. Menu

#2

Post by Midgardsormr » Mon Jul 01, 2019 11:09 am

Try comp:Path(), perhaps?

User avatar
SirEdric
Fusionator
Posts: 1753
Joined: Tue Aug 05, 2014 10:04 am
Answers: 1
Real name: Eric Westphal
Been thanked: 80 times
Contact:

Re: Inconsistent Code Behavior: Console vs. Menu

#3

Post by SirEdric » Mon Jul 01, 2019 11:24 am

As an explanation, the console (as well as expressions on tools themselves) already carry things like CurrentTime or those shortcuts to Path().
In an 'external' script you have to pass the values along as @Midgardsormr said.

dpower
Posts: 2
Joined: Fri Jun 28, 2019 6:57 pm
Real name: David Power

Re: Inconsistent Code Behavior: Console vs. Menu

#4

Post by dpower » Mon Jul 01, 2019 11:44 am

@Midgardsormr... That did the trick nicely! Thank you.

@SirEdric... Thanks for the details. I'm finding the object model and syntax a little challenging at the moment. But I remain optimistic.

Thank you both!