Lightroom SDK: Getting Started Tutorial Documentation Example Code Fails

  • 1
  • Problem
  • Updated 2 years ago
I defy anyone to simply copy and paste the sample code documented in 'CHAPTER 9: Getting Started: A Tutorial Example', 'Displaying a custom dialog' section into the 'LibraryMenuItem.lua' file AND have it work without correcting it.

There are easily 2 errors in this section of the document:

1) value = “Some Text”,

Should read instead: value = "Some Text",

2) contents = c, -- the view hierarchy we defined

Should read instead:

contents = c -- the view hierarchy we defined

IN ADDITION to NOT properly documenting where specifically the

'local result = LrDialogs.presentModalDialog( ...) }'

code snippet goes within the lua file being constructed.

I can only assume that the rest of this SDK documentation is equally as poor.

I hope someone can point me to a better source of documentation for the SDK.
Photo of Richard Henley

Richard Henley

  • 50 Posts
  • 3 Reply Likes
  • frustrated

Posted 5 years ago

  • 1
Photo of John R. Ellis

John R. Ellis, Champion

  • 3863 Posts
  • 1017 Reply Likes
The examples in Chapter 9 are also in the SDK folder Sample Plugins. The helloworld.lrdevplugin folder contains the sample plugin you're referring to. I just tried it in LR 5, and it works. In that folder, what the SDK Guide calls LibraryMenuItem.lua is called ShowCustomDialog.lua.

With regard to:

1) value = “Some Text”,

Looks like the tech writer forgot to turn off "smart quotes".

With regard to:

2) contents = c, -- the view hierarchy we defined

I'm not sure why you think that doesn't work? Lua table syntax allows a trailing comma, e.g. {a = 1, b = 2,} is exactly the same as {a = 1, b = 2}.

In general, I found the SDK documentation acceptable but far from great. The SDK hasn't gotten much love from Adobe since LR 3, in my opinion.

A good place to post questions about the SDK is:

http://forums.adobe.com/community/lig...

Several of us are active there and try to help out the (small) SDK community.
Photo of Richard Henley

Richard Henley

  • 50 Posts
  • 3 Reply Likes
Because the ',' in #2 implies additional code to follow when there is none. It generates an error when it is there in LR4 and the code fails to execute properly for me, possibly it works for you.

I didn't report this as a bug against properly constructed sample code that is NOT referenced by this section of the tutorial documentation.

I logged this against the actual written documentation in this section of the tutorial because it is incorrect. And using it as documented causes the code to fail. And that to me in a example tutorial exercise is NOT acceptable.

IF someone is slowly working through the tutorial BECAUSE they know next to nothing about the SDK how can one possibly construct a clear question when the documentation is incorrect and misleading? It is not as if there is a clear debug strategy available in the software to locate the precise problem encountered.
Photo of James Kayten

James Kayten

  • 3 Posts
  • 0 Reply Likes
It's 4 years later and I've just come across this having the same issue.  Every bit of code is exactly as instructed and I have to spend time wondering what's wrong.  I'm not wanting to master coding, I just want to write what I need.
Photo of John R. Ellis

John R. Ellis, Champion

  • 3845 Posts
  • 1008 Reply Likes
Unfortunately, Adobe support for the SDK is almost non-existent at this point. A couple of suggestions to make progress:

- Use the sample code in the "Sample Plugins" folder rather than copying from the SDK Guide.

- It's pretty hard debugging plugins, since LR often silently ignores errors (and when it doesn't, the error message is unscrutable).   The SDK forum has some posts about better debugging and participants who can help out.
Photo of James Kayten

James Kayten

  • 3 Posts
  • 0 Reply Likes
Thanks for the help!  I'm glazing over reading the LUA manual when all I want is an answer to a specific question; what's the significance of the colon in this line -

  1. renditionToSatisfy:renditionIsDone( success, message ) 



Photo of John R. Ellis

John R. Ellis, Champion

  • 3845 Posts
  • 1008 Reply Likes
The colon indicates method access to an object.  Given an object o, o:m(x) is the same as o.m(o, x).  In your example, the method "renditionIsDone" is being invoked on the object "renditionToSatisfy".  As very common mistake is to write "." instead of ":', which will result in an inscrutable assertion failure.

Feel free to post further questions on the SDK forum.
Photo of James Kayten

James Kayten

  • 3 Posts
  • 0 Reply Likes
Will do.  Thanks again
Photo of John R. Ellis

John R. Ellis, Champion

  • 3863 Posts
  • 1017 Reply Likes
I don't want to diminish your general feedback on the SDK documentation, but it's important to clarify the issue with comma so others aren't misled in the future.

You wrote, "the ',' in #2 implies additional code to follow when there is none. It generates an error when it is there in LR4 and the code fails to execute properly for me, possibly it works for you."

Without seeing the entire code in question, I don't know what your actual error is. But the error would not be caused by the trailing comma. As I mentioned, that is valid Lua syntax, and it is a common coding convention among many Lua programmers to use comma as a terminator rather than a separator (much as programmers in many languages use ";" as a terminator rather than a separator between statements).

For example, if you look at Sample Plugins]helloworld.lrdevplugin\Info.lua, you'll see that comma terminates every item in the arrays LrExportMenuItems and LrLibraryMenuItems.