Seems like a simple thing but I haven't found an answer.
Custom script. How do you return a variable?
Specifically, I want to return copiedLayer.
(define (script-copy-first-layer inImg)
(let*
(
(layers (cadr (gimp-image-get-layers inImg) ) )
(numLayers (car (gimp-image-get-layers inImg) ) )
(layer (aref layers 0))
(copiedLayer (car (gimp-layer-copy layer TRUE)))
)
(gimp-image-add-layer inImg copiedLayer 0)
(gimp-layer-set-visible copiedLayer TRUE)
(gimp-layer-set-lock-alpha copiedLayer TRUE)
(gimp-layer-add-alpha copiedLayer)
)
)
(script-fu-register
"script-copy-first-layer"
"<Image>/Image/Copy First Layer"
"Copy First Layer"
"Black Orchid Studios"
"Black Orchid Studios"
"July 2017"
"RGB*, GRAY*"
SF-IMAGE "Image" 0
)
Simply add copiedLayer
to the end of the let
statement.
I believe this is what you need:
(define (script-copy-first-layer inImg)
(let*
(
(layers (cadr (gimp-image-get-layers inImg) ) )
(numLayers (car (gimp-image-get-layers inImg) ) )
(layer (aref layers 0))
(copiedLayer (car (gimp-layer-copy layer TRUE)))
)
(gimp-image-add-layer inImg copiedLayer 0)
(gimp-layer-set-visible copiedLayer TRUE)
(gimp-layer-set-lock-alpha copiedLayer TRUE)
(gimp-layer-add-alpha copiedLayer)
copiedLayer
)
)
(script-fu-register
"script-copy-first-layer"
"<Image>/Image/Copy First Layer"
"Copy First Layer"
"Black Orchid Studios"
"Black Orchid Studios"
"July 2017"
"RGB*, GRAY*"
SF-IMAGE "Image" 0
)