
local renderTargets = octane.nodegraph.getRootGraph():findNodes(octane.NT_RENDERTARGET)
I would like to get a table back that holds all of the render target nodes in the root graph. Thanks,
items
property of a combo box.Code: Select all
local renderTargets = octane.nodegraph.getRootGraph():findNodes(octane.NT_RENDERTARGET)
-- the hash operator gives the length of the array (which is actually a table with integer keys)
print(#renderTargets)
names = {}
-- ipairs() returns an iterator object, which returns the integer keys and associated values in the array.
for i, rt in ipairs(renderTargets)
do
names[#names + 1] = rt:getProperties().name -- In an array the keys start at 1
end
for i, n in ipairs(names)
do
print(n)
end
names[i]
.Code: Select all
t[1] = "a"
t[2] = "b"
t[3] = "c"
Code: Select all
[code]
t[1] = "a"
t[2] = "b"
-- key 3 is not defined.
t[4] = "d"
#t
and ipairs(t)
may assume there are only 2 elements in the array. Using t[#t + 1]
makes sure you always insert with the next available key.Code: Select all
renderTargetDropDown:updateProperties { items = RENDER_TARGETS, selectedItem = RENDER_TARGETS[1] }
grimm wrote:Just another question about the code you wrote:
Do you have to do names[#names + 1] or can you just do names ?
table.insert(names, rt:getProperties().name)
. For more info see http://www.lua.org/manual/5.1/manual.ht ... ble.insert.Hi grimm,grimm wrote:I'm having another problem, this time with the combo box component. I can't set the default selected item in the drop down list. I'm trying to set it with this line of code:
RENDER_TARGETS is the array of item, and they do show up in the drop down. What do you set the selectedItem to in order to set it? In the API docs it does say that this property is writable so it should be possible to set it, is that right? Thanks,Code: Select all
renderTargetDropDown:updateProperties { items = RENDER_TARGETS, selectedItem = RENDER_TARGETS[1] }