Page 1 of 1

Accessing application preferences in Lua

PostPosted: Tue Jan 07, 2014 4:32 am
by stratified
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

Re: Accessing application preferences in Lua

PostPosted: Tue Jan 07, 2014 4:58 am
by Tugpsx
Awesome! Thanks with the next release and combined with the object loader this should be key to storing and recalling paths