Variables in Lua Script not persistent?

Hi Guys.

It's been a while :-)

So I have this little piece of code to concat multiple text snippets until a certain limit of characters is reached:

--------------

--$ inTextIn text change
--$ inLIMIT integer
--$ outTextOut text
--$ outCount integer

if inTextIn_Changed then
    if #outTextOut + #inTextIn + 1 >= inLIMIT then
        outTextOut = inTextIn .. "-"
    else
        outTextOut = outTextOut .. inTextIn .. "+" 
    end
end
outCount = #outTextOut

----------
 ('+' and '-' are for debugging only)

According to this post: https://my.aximmetry.com/post/2483-triggering-a-script
the outTextOut is meant to be persistent, but every time inTextIn changes the output is inTextIn *only*,
the original 
outTextOut is lost.

Is there anyway to achieve *real* persistency?
(Running 2025.1.0 here for various reasons)

Cheers & all the best.

Eric.


   EricWest

Comments

EricWest
  -  

As a side note... I managed to mimick the desired behaviour with this piece of node setup.
Looks weird, but works.
I still think the script would have been the 'cleaner' solution though :-)

Variables in Lua Script not persistent?

Patrik@Aximmetry
  -  

Hi,

There may have been a misunderstanding. The values on the output pins persist until the script is next executed, but the output variables inside the script do not. Global variables, however, do persist.
If you wish to store an output value, we suggest storing it in a separate variable inside the script and then reading it back.

 

Best Regards,
Patrik