[JW Lua] JWLua scripts
Jari Williamsson
jari.williamsson at mailbox.swipnet.se
Mon Sep 16 22:19:09 CEST 2013
Charles (and everyone else),
Here are some comments on the source code.
Replace:
dialog:SetInitValues(useLayer[1],useLayer[2],useLayer[3],useLayer[4])
with:
dialog:SetInitValues(useLayer)
(The dialog setters can use a single table as parameters - and tables
SHOULD be used in really large dialog boxes with loads of options. In
the 0.05 Wiki docs, I recommend using a single table from around 6 options.)
The SwapLayersRegion.lua has an error (for the reason why I said it is
easy to make errors by using the region directly).
This line is the problem:
for staff = startStaff,endStaff do
A staff number in Finale can be ANY 1-based number and the staves can
appear in ANY order. It's an error to assume that the staves at the top
of the score always have a lower staff ID number.
Instead you should use the SLOT number for the region, which is linear
within the region - and then convert the slot to a staff number through
the region object.
This would be the replacement code:
local region = finenv.Region()
for slot = region.StartSlot, region.EndSlot do
local staff = region:CalcStaffNumber(slot)
Also, that same script manually checks for empty regions. However, that
code will never run, since you've also defined the plug-in with:
finaleplugin.RequireSelection = true
So if the user haven't selected a region in this case, JW Lua will
display a message to the user before the plug-in even starts.
On 2013-09-16 21:22, Charles O. Lawrence wrote:
> Believe me, it is not as easy to get started as it
> may first appear. The learning curve is steep, and JWLua is nothing
> like FinaleScript.
And believe me, if you have ever tried to use the Finale PDK directly,
the JW Lua learning curve is nothing. ;-)
I guess more developers will have an increased interest when we get
closer to a "version 1.0". I really appreciate that you're trying JW Lua
at such an early stage. Your feedback is very valuable - thanks!
Best regards,
Jari Williamsson
More information about the JWLua
mailing list