It's not quite as straightforwards as you (we all) would want it to be.
First, you can use object.getInputs() to get a table of input existing on it. Then, you have to choose the one you want to edit and extract its index. Finally, you can use object.editInput(...), passing the index there along with any values you want to modify. If you only have one input it's fine because you don't have to look for it. It gets more complicate with more inputs as you have to identify them through one of their properties, e.g. input_function. If you have some with identical ones, tough luck, gotta look at other parameters too.
Code:
-- Let's say we simply want to set a value of an input to newString when there's only one on an object
function SetInputValue(newString)
local inputs = self.getInputs()
local editIndex = inputs[1].index or error('No input found!')
self.editInput( {index = editIndex, value = newString} )
end
-- If we have many inputs, let's say they all have different input_function
-- This will set value to newString for an input that has input_function set to whatever you pass as inputFcnName
function SetParticularInputValue(inputFcnName, newString)
local inputs = self.getInputs()
for _,data in ipairs(inputs) do
if data.input_function == inputFcnName then
self.editInput( {index = data.index, value = newString} )
return
end
end
error('No input with function_name \'' .. inputFcnName '\' found!')
end
You can of course delete the error functions if you want it to simply not do anything if there was no valid input. But IMO explicit erroring is better than failing silently.