New to Scripting LUA but...

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
Chimp
Posts: 7
Joined: Sat Jul 09, 2016 7:31 am

New to Scripting LUA but...

Post by Chimp »

Hi there,

I'm new to LUA. I've just started today reading about LUA and scripting for Anime Studio. I have a B.S. in Information System/Network Security, so I'm familiar to developing apps in general. However, I've been away from it for a while so I'm a little rusty. I also have my MFA in Creative Writing and a "minor" in Film Production, been to film school and bla bla bla. That last part was to give an idea about how long I've been away from actual programming.

I'm familiar with compilers and such. However, to me, from what I've read, LUA doesn't actually compile until you run it in AS. Is that correct?
AS/Moho (or w/e it's called nowadays) takes the file and runs it when you call to it under the Scripts option? And that's the only real way to find out if the script is working or not?

With that out of the way, I am on a Macbook Pro. I also have a Windows video editing station as well, so I can do either in both. On Windows, I use Notepadd++, and on Mac, I use Sublime.

I am a little hung up on the Make/Makefile part of this for Mac. Is there an actual compiler or something that I'm missing to test its function before bringing my script into AS? Or because AS is both the Fronted and Backend of the script, that's the only way to tell if the script is working?

I haven't skimmed through this area of the forum yet to see if any of my questions have been answered yet. So, please bare with me.

Is there an interface to LUA - scripting? Or, is text-base developing pretty much it?

Thanks
User avatar
synthsin75
Posts: 9964
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: New to Scripting LUA but...

Post by synthsin75 »

Welcome to the forum, AS, and Lua scripting. AS reads in scripts when it starts, and only evaluates code when the tool or script is invoked. The only way to test scripts is in AS, since that's the only access to the AS API for Lua. It's easier than it sounds. Just remember that ctrl+alt+shift+L reloads scripts, so you'll need to do this often, to check whether recent changes are working or you've corrected an error reported by the AS Lua console. Right now the console seems to spit out a handful of the last reported errors, so you only need to pay attention to new ones.

There a few text editors that have Lua syntax highlighting (I've never found much use for it though). Nothing needs compiling.
obtusity
Posts: 75
Joined: Tue Jan 12, 2016 2:30 am

Re: New to Scripting LUA but...

Post by obtusity »

As noted by synthsin75, scripting/interpreted languages such as Lua/Python/Javascript, unlike compiled languages, are usually interpreted directly, like a batch file, there is neither compiler nor Makefile. There is only the interpreter, in this case built into Moho/AS.
You could run your code externally to check the Lua syntax using an external Lua interpreter, but you would have to define lots of mock/dummy objects/functions to prevent errors for all the Moho/AS API calls.

It's pretty much text editing and testing in the program.

Apart from syntax highlighting, some text editors will also provide syntax checking (linting), usually as a plugin or extension - for example, Sublime Text has https://github.com/SublimeLinter/SublimeLinter-lua. Alternatively, you should be able to call a linter (e.g. luacheck) as an external program from the text editor.

If you are willing to put in the effort, many good editors will also provide API support (tooltips for function parameters, lookup for variable/constant names, etc), if the information is supplied in the appropriate editor-specific format. So, you could convert the files that come in C:\Program Files\Smith Micro\Anime Studio Pro 11\Resources\Support\Extra Files\Lua Interfaces.zip (in Windows) to the appropriate API support files for a specific editor. However, I don't know of any existing prepared API files - you'd have to do the work yourself. You could also create a snippets library for both standard Lua functionality and for the Moho/AS API.

As far as I know, there is no graphical IDE (for Lua, let alone the Moho/AS API) that adds anything more than a text editor would.
Post Reply