Gimp (Scheme) 你如何 return 来自脚本的变量?

Gimp (Scheme) How do you return a variable from a script?

看起来很简单,但我还没有找到答案。

自定义脚本。你如何return一个变量?

具体来说,我想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
)

只需将copiedLayer添加到let语句的末尾即可。

我相信这就是您所需要的:

(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
)