
I use Fusion primarily on a Mac Laptop, so I will use macOS based filepaths for this reply but you can do the exact same steps on Windows by translating the general concepts.
Are you running fuscript with the path to an existing Lua script, or trying to use the fuscript interactive prompt? Try running a .lua file off disk and see if it works better for you.
You could look at manually defining the LUA_PATH and LUA_CPATH environment variables on your system in the command line session. Then fuscript should pick up the settings you want to use automatically when you launch a lua script from the command line.
On a macOS or Linux system you would use the export command in the terminal. (On Windows you would define the environment variables in the System Control Panel > Advanced System Settings > Environment Variables... window.)
- Code: Select all
export LUA_CPATH="/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Modules/Lua/?.so;"
export LUA_PATH="/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Modules/Lua/?.lua;"
When you define a LUA_PATH environment variable each folder path entry in the list needs to end with "/?.so;" (Linux/macOS) or "/?.dll;" (Windows).
When you define a LUA_CPATH environment variable each folder path entry in the list needs to end with "/?.lua;".
The "package.path" and "package.cpath" constant values in Lua can be printed out and they will let you see what the active Lua modules path values are in your current fuscript session.
Save the following code to a .lua file and then run it in fuscript, and also run it for comparison in the Fusion Console window:
- Code: Select all
print('\n\n[LUA_CPATH]')
print(package.cpath)
print('\n\n[LUA_PATH]')
print(package.path)
If you want to open a Resolve based fuscript session and connect to Resolve and the Fusion page variables you could use a command line snippet like this macOS example below. (To use this command on Windows, switch the fuscript path in the example over to use the reall Windows based fuscript path):
- Code: Select all
'/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fuscript' -l lua -x 'fusion = bmd.scriptapp("Fusion", "localhost");if fusion ~= nil then fu = fusion;app = fu;composition = fu.CurrentComp;comp = composition;SetActiveComp(comp) else print("[Error] Please open up the Fusion GUI before running this tool.") end;resolve = bmd.scriptapp("Resolve", "localhost");if resolve ~= nil then res = resolve;else print("[Error] Please open up the Fusion GUI before running this tool.") end;' '/Users/andrew/Desktop/fuscript module path.lua'
Running this command on my macOS system results in the following output in the terminal:
- Code: Select all
[LUA_CPATH]
/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Modules/Lua/?.so;
[LUA_PATH]
/Library/Application Support/Blackmagic Design/DaVinci Resolve/Fusion/Modules/Lua/?.lua;
With no environment variable override defined for LUA_CPATH and LUA_PATH I get back the following output in the terminal:
- Code: Select all
[LUA_CPATH]
./?.so;/usr/local/lib/lua/5.1/?.so;/Users/macbuild/build/remote_bmd-eng_TEi2/bmdcpt-temp/install/LuaJIT-2.1.0_2/mac///lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
[LUA_PATH]
./?.lua;/Users/macbuild/build/remote_bmd-eng_TEi2/bmdcpt-temp/install/LuaJIT-2.1.0_2/mac//share/luajit-2.1.0-beta3/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/Users/macbuild/build/remote_bmd-eng_TEi2/bmdcpt-temp/install/LuaJIT-2.1.0_2/mac//share/lua/5.1/?.lua;/Users/macbuild/build/remote_bmd-eng_TEi2/bmdcpt-temp/install/LuaJIT-2.1.0_2/mac//share/lua/5.1/?/init.lua
If I drag this same lua script into the Resolve Fusion page console view I get the output shown in this screenshot: