synthsin75 wrote: ↑Sat Mar 11, 2023 6:57 pm
I usually use the Lua OS functions for file handling, but seeing lfs.chdir (path), I wonder if that's a possible way to change Moho's working directory...so you can point an open file dialog to a specific directory, instead of always the last directory Moho opened.
Same here! But they are quite limited and, even Moho also offers some functions that can help when dealing with files, I always had missed can access file attributes and e.g. be able to create/remove directories and so, things that although I've not tested yet, "lfs" should be able to do with ease. E.g. I had to use recently kind of a hack to simply can test if a file already exits in a directory or not and, precisely yesterday, I realized it wasn't even reliable after all; well as I understand, with
lfs this kind of things should be easy peasy, so for me it has been like an unexpected gift around all this situation
Oh, but at first sight at least, it doesn't sound to me like "lfs.chdir" can do what you wonder, or at least unless I'm missing something. I've done a quick test anyway by simply calling it just before what makes open the "open file dialog" in "lm_automation.lua" meu script and, as kind of expected, it continue opening in the last directory used by Moho. OTOH, what it does indeed is change "lfs" working directory as "lfs.currentdir()" reveals, meaning everything seems to work! (Can't wait to start giving some real use to it).
synthsin75 wrote: ↑Sat Mar 11, 2023 6:57 pm
So set and run a layerscript once, at the beginning of a render, to load functions into the Lua render environment?
You'd already have to have a variable hard-coded in the layerscript, right?
Yes! And I can't believe it yet it seems to work... Still testing things though, because I've spend a lot of time today treating to make work the combo "string.dump" & "load" Lua functions (just to know if I could have another alternative should the first one reveal problematic at some point), but without any success because I can't get
moho to be passed as valid argument upon calling the "binary stringed" function, for some reason that I simply can't (and neither Bing AI) understand... Therefore I'm afraid I'm tied to my workaround for now, so I hope it continue working without surprises.
But what do you mean by
variable hard-coded? There is nothing special about the functions I want to call from other scripts, I just want they to be available "in memory" so that they can be called at anytime and from anywhere, and loading them that way seems to guarantee (still can hardly believe it

) that, since now they appear as any other available variable in the new/fresh environment as well.
...