Chagai Z. answered 24d
Technology Instructor Specializing in Adobe Premiere for Video Editing
The dialog box is probably not fixing the real problem. It is most likely slowing the script down or changing the timing just enough that the bug does not show up. That is a common trap when using message boxes for debugging.
In your code, I would first look at the Image table and the way it is being reused. You create Image once before the loop, then keep adding values to the same table. When you do table.insert(tblImages, Image), Lua inserts a reference to that same table, not a fresh copy. So if you are processing multiple images, you should create a new Image table each time you detect a new image, especially after inserting the previous one.
I would also check this line:
LrDialogs.message(Image.name .. Image.iso .. Image.filmSim .. Image.drMode .. Image.dr)
If Image.dr is nil, Lua cannot concatenate it with strings. The safer test is:
LrDialogs.message(
tostring(Image.name) ..
tostring(Image.iso) ..
tostring(Image.filmSim) ..
tostring(Image.drMode) ..
tostring(Image.dr)
)
That will show you which value is actually missing instead of crashing. Then you can trace back and ask: did the file actually contain the “Auto” or “Development” line that sets Image.dr? If not, Image.dr will stay nil.
So I would fix it in this order:
- Do not rely on LrDialogs.message as the fix. Use it only as a clue.
- Create a new Image = {} for each new image record.
- Use ipairs instead of pairs if the output lines must stay in order.
- Use tostring() while debugging so nil values do not crash the message.
- Add a default value for Image.dr if that field is optional.
The core issue is likely not the Lightroom dialog box itself. It is probably a combination of table reuse, order of parsing, and one field not being assigned before it is concatenated.