Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2017-11-05 13:47:50

JimR
Member
Registered: 2012-11-30
Posts: 348
Website

The Special {LUA=...} Token

Using the LUA code execution option worked in the CE4 galleries. I tired it in Backlight, but found it caused LR to hang during publish. A little bit of LUA script was useful.

Consider the following example:

{Caption} - {Month} {YYYY}

If the image doesn't have a caption, then the figure in the presentation page will display " - May 2015" instead of "My Photo - May 2015"

I had been using the following code in CE4.

{LUA=
if Caption ~= ""
  then
    return sprintf("%s - %s %s", Caption, Month, YYYY)
  else
    return sprintf("%s %s", Month, YYYY)
end
}

The real issue is that there isn't a way to squelch (hide) " - " if the {Caption} is empty. Maybe there's another way?


--Jim

Offline

#2 2017-11-06 04:05:37

JimR
Member
Registered: 2012-11-30
Posts: 348
Website

Re: The Special {LUA=...} Token

I double checked this morning, and tried using the example {LUA=...} below taken from the documentation page. It causes LR to hang. Then before I publish anything again, I have to restart LR. I'm using the latest LR Classic.

{LUA=if Artist ~= "" then return sprintf("Copyright %s", Artist) end}

Here's my workaround for the moment. I create a caption is one if missing.

{Caption|"Untitled"} - {Month} {YYYY}

With the above, if there is no caption then the output is "Untitled - May 2015". I hate "untitled" as a title, but I'll live with it till the bug is fixed. This avoids output such as " - May 2015"

Last edited by JimR (2017-11-06 10:03:29)


--Jim

Offline

#3 2017-11-06 06:40:54

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: The Special {LUA=...} Token

Hi Jim, thanks for looking into this.  There is unfortunately very little chance of any Lua bugs being fixed.  I'll try to see if I can find a user-land solution to what you're trying to achieve.

Offline

#4 2017-11-06 12:28:07

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: The Special {LUA=...} Token

The code you used in CE4 works for me.  Two images published, one with a caption (bike) and one without, produce the following Metadata:

bike - November 2003
January 2005

That raises the question of why it hangs for you under Backlight while it worked under CE4.  I tested under LR Classic 7 on a Mac.  My Tokens field is set to:

{LUA= if Caption ~= ""   then     return sprintf("%s - %s %s", Caption, Month, YYYY)   else     return sprintf("%s %s", Month, YYYY) end }

Offline

#5 2017-11-06 14:23:40

JimR
Member
Registered: 2012-11-30
Posts: 348
Website

Re: The Special {LUA=...} Token

Ben wrote:

That raises the question of why it hangs for you under Backlight while it worked under CE4.  I tested under LR Classic 7 on a Mac.

Hmm. Curious. I verified it does hang LR for me, where I have to restart LR to publish anything after attempting that LUA script. I also have LR Classic 7.

Where to go from here? Is there a cache to clear? Some way to debug this? A log file to generate?


--Jim

Offline

#6 2017-11-06 21:57:56

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: The Special {LUA=...} Token

There's probably not a lot to go on.  Such errors would happen within the internals of LR's Lua engine.  We have the ttg.log, under your Documents directory.  Log messages are sometimes available from the plug-in manager.  To find them, open the LR Plug-in manager (File > Plug-in Manager), select the "Publisher, By The Turning Gate" plugin, and see whether the Save Diagnostic Log to File button within the Plug-in Author Tools section is enabled and produces anything interesting when saved.

Offline

#7 2017-11-07 01:23:18

JimR
Member
Registered: 2012-11-30
Posts: 348
Website

Re: The Special {LUA=...} Token

Ben wrote:

We have the ttg.log

I forgot about that file. Looking in it just now, wow, it contains nearly half a million lines! It's well over 100MB. 80,000 lines from just this year, mostly while developing with Backlight.

I've been a TTG user for many years wink


Let me see if I can get any further or flush out any details. I really do want the LUA code working. I can't think of a good workaround to what I had in CE4.


--Jim

Offline

#8 2017-11-07 08:06:26

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: The Special {LUA=...} Token

Hi Jim, it's good to see you've made good use of Publisher over that time smile

Perhaps a long shot, but can you see whether the below code works for you?  It adds a check for nil before checking for an empty value.

{LUA= if Caption ~= nil and Caption ~= ""  then     return sprintf("XXX%s - %s %s", Caption, Month, YYYY)   else     return sprintf("YYY%s %s", Month, YYYY) end }

Attempting to operate on nil values has caused us problems in the past.  It may be that your LR has nil values when captions aren't set.

Offline

#9 2017-11-07 12:07:55

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: The Special {LUA=...} Token

That seems to work very nicely for me, Ben.


Matt

The Turning Gate, http://theturninggate.net

Offline

#10 2017-11-07 16:37:10

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: The Special {LUA=...} Token

Hi Matt, you'll probably find that Jim's earlier version works nicely for you too.  Can you try it out to see whether that fails for you? (it works for me but not Jim):

{LUA= if Caption ~= ""   then     return sprintf("%s - %s %s", Caption, Month, YYYY)   else     return sprintf("%s %s", Month, YYYY) end }

I'm trying to find an alternative that may overcome whatever it is that makes it hang in LR for Jim.

Offline

#11 2017-11-08 13:14:58

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: The Special {LUA=...} Token

Yes, that version also works for me. Which is funny, because I had tried it before and I recall have mixed results. I might have been messing around with it, though, so that may have been an error of my own design.


Matt

The Turning Gate, http://theturninggate.net

Offline

#12 2017-11-12 05:28:32

JimR
Member
Registered: 2012-11-30
Posts: 348
Website

Re: The Special {LUA=...} Token

I tried everything I could think of, but any use of {LUA=...} causes Lightroom to hang. Even this simple example:

{LUA=Caption}

I experimented using a new test album with just two images.

The TTG log file is normal, but at the point where the image is to be uploaded the log stops (at the point where it hangs).

So I'm stuck. Nothing I've tried will get any use of LUA= to work. It always causes LR to hang during publish.


--Jim

Offline

#13 2017-11-12 19:32:17

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: The Special {LUA=...} Token

Hi Jim, I've reached out to an expert on Lua handling in Lightroom, and will let you know if he can provide any insight on this.

Offline

#14 2017-11-13 11:35:53

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: The Special {LUA=...} Token

Hi Jim, paraphrased from the expert wink :

Plugins shouldn't be able to hang Lightroom.  Is it a case that you have to restart Lightroom after trying to use the LUA= syntax?
The Lua handling shouldn't be specific to the system you're running on.  Two areas that may vary between installations are your catalog, and preferences.

1. Issues may be catatalog-specific.  Try checking the catalog's integrity and optimising the catalogue.  If that doesn't help, try publishing from a different catalog.

2. If that doesn't correct the problem, then try to see whether trashing your preferences helps.  This can fix various LR issues, even if they seem completely unrelated to the preferences. 


Of course, with the above, make sure to take all due precaution, such as by backing up your catalog and LR preferences, so that you don't lose any settings or data.

Offline

#15 2017-11-13 14:36:31

JimR
Member
Registered: 2012-11-30
Posts: 348
Website

Re: The Special {LUA=...} Token

Ben wrote:

1. Issues may be catatalog-specific.  Try checking the catalog's integrity and optimising the catalogue.  If that doesn't help, try publishing from a different catalog.

Yup, did all that already and a few similar ideas along that line.

Ben wrote:

2. If that doesn't correct the problem, then try to see whether trashing your preferences helps.  This can fix various LR issues, even if they seem completely unrelated to the preferences.

Whoa! Deleting preferences and then publishing worked! WTF?!

Write that down!


--Jim

Offline

#16 2017-11-13 19:18:07

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: The Special {LUA=...} Token

JimR wrote:

Whoa! Deleting preferences and then publishing worked! WTF?!

Write that down!

That's great!  WTF indeed on that fixing it.  It makes me wonder how LR operates behind the scenes.

Offline

#17 2017-11-13 21:52:02

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: The Special {LUA=...} Token

It is rather disconcerting the number of problems trashing the preferences seems to solve. But I’m glad it usually works....


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#18 2017-11-13 22:23:26

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: The Special {LUA=...} Token

Seems akin to punching the television to improve reception, or punching the refrigerator to quiet it. I've had astounding success punching these and other appliances, not that I understand it. Makes me wish Lightroom had something I could punch, though.


Matt

The Turning Gate, http://theturninggate.net

Offline

Board footer

Powered by FluxBB