Accessing application preferences in Lua

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
User avatar
stratified
OctaneRender Team
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Hi all,

On request we've added access to the user's preferences in lua. Don't worry, credentials aren't accessible in lua.

In Octane, preferences are stored in an internal node of type octane.NT_LOCAL_APP_PREFS. You can fetch it by calling octane.project.getPreferences(). Getting and setting preferences is a matter of manipulating a node.

Here's a small example:

Code: Select all

-- get the local preferences node
local prefs = octane.project.getPreferences()

-- get the directories
print(prefs:getAttribute(octane.A_LAST_PROJECT_DIRECTORY))
print(prefs:getAttribute(octane.A_LAST_IMAGE_DIRECTORY))
print(prefs:getAttribute(octane.A_LAST_GEOMETRY_DIRECTORY))
print(prefs:getAttribute(octane.A_LAST_RENDER_DIRECTORY))

-- update the script image directory, if you would check your preferences in the
-- standalone, they've changed.
prefs:setAttribute(octane.A_SCRIPT_DIRECTORY, "/tmp/")
If you can, always avoid modifying a user's preferences. If you can't be transparent about it. Silently modifying a user's preferences is not cool!

If there are any questions, just ask.

cheers,
Thomas
Tugpsx
Licensed Customer
Posts: 1150
Joined: Thu Feb 04, 2010 8:04 pm
Location: Chicago, IL
Contact:

Awesome! Thanks with the next release and combined with the object loader this should be key to storing and recalling paths
Win 11 64GB | NVIDIA RTX3060 12GB
Post Reply

Return to “Lua Scripting”