I've not done anything with Lua
Lua is probably the simplest, cleanest programming language I know. (And I know a few.)
Lua's simplicity is also its biggest weakness: being a small, clean language by design, it doesn't have a lot of stuff built into it that you'd expect to find when coming from an industrial-grade language like Java, or a batteries-included language like Python.
Lua is designed to be extended by C, which in this case means Lightroom's SDK. That's great if Adobe's done the work to provide the tools you need that aren't built into Lua, but every now and then you'll probably find yourself calling out to external tools to get things done.
Is the Lightroom API easy to hook into
The only tricky part about it is that you need to structure your source code in a particular way and provide a special
Info.lua file to tell Lightroom about your plugin. It's all explained in the SDK docs. The SDK includes several functioning plugins to start from, including a fairly elaborate "hello world" plugin which can be scavenged for useful starting code.
does it require any specialized tools for development?
You can get by with just a text editor.
There is no debugging facility built into Lightroom, but there is a debug logging facility in the SDK. You can catch these messages in either
WinDbg on Windows or
Console on OS X.
A more recent development is the open source ZeroBrane Studio Lua IDE. You can use this instead of another text editor, but the really cool bit is that it is possible to attach it to your running plugin which lets you debug it as it runs. I've tried this, and it does help reduce the fix/reload/restart debugging cycle time.
Can I write scripts to perform the kind of tasks I describe above easily?
I don't think either task is 100% do-able using only the Lightroom SDK, but it can do a lot of the work for you.
select the file in each stack with the JPG extension and make it the top of the stack
Here's some vaguely Lua-like code to get you almost all the way there:
for photo in catalog:getMultipleSelectedOrAllPhotos() do
for peer in photo:stackInFolderMembers() do
if string.find('%.jpg$', peer:getFormattedMetadata('fileName')) then
-- *mumble* move 'peer' photo to top of stack *mumble*
Unfortunately, I don't see a way in the SDK to do that innermost comment line's action, as of LR 5 at least. The best I can come up with is to call
catalog:setSelectedPhotos(peer), then leave it to the user to actually click the number badge to reorder the stack.
Perform a mass copy of metadata from an (existing) RAW file to an (existing) JPEG file
You can do some of this with the existing SDK, but there are limitations.
For example, while you can read the value of the EXIF
dateTimeOriginal field, there is no facility in the SDK itself to set the value. I assume this is because the Lightroom developers decided this shouldn't ever be changed programmatically, that it is precious information from the camera. (Why that should be the case when there is a Metadata > Edit Capture Time... menu item I don't know, but there you have it.)
But, whenever the SDK tries to trap you with one of these limitations, there is often an escape hatch. You can install ExifTool and call out to it from Lua, for example. That's not a perfect solution, because you then have an inconsistency between the catalog metadata and the photo metadata, but Lightroom will notice and put a badge on the photo, which when clicked will let you resolve the conflict by reloading the metadata from the photo.
(You'll want to have the "Automatically write changes into XMP" option set in the Catalog Settings dialog when using such a plugin. Otherwise, you make it easier to create a two-way conflict, where both the catalog and photo metadata have changed. Lightroom doesn't know how to merge the two sets of metadata; it makes you pick one, and it overwrites the other metadata copy with it.)