Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error: Not enough arguments?
#1
I'm trying to self-taught about writing a script-fu script in GIMP and trying to create a simple script, a "New image". When I'm trying to run it it will give me the error "Not enough arguments". What am I missing? Thank you in advanced.

Code:
(define (script-fu-new-image theImage theLayer)    
 (let* ((theImage  (car (gimp-image-new 500 500 RGB)))
         (baseLayer (car (gimp-layer-new theImage 500 500 RGB-IMAGE "Wood" 100 LAYER-MODE-NORMAL)))  
        )
      
      (gimp-image-undo-group-start theImage)
      
      (gimp-image-insert-layer theImage baseLayer 0 0)
      (gimp-drawable-fill theLayer FILL-WHITE)
      (gimp-display-new theImage)
      
      (gimp-image-undo-group-end theImage)
      
 )
)
       
      

    




(script-fu-register
    "script-fu-new-image"                        
    "<Image>/File/Create/New image"
    "New image"                                  
   "Creates a New image"    
   "Pocholo"                            
   "Pocholo"
   "March 2020"                          
    ""
    
    

)
Reply
#2
What is that theLayer variable that you use?
Reply
#3
Hello Pocholo, Smile

The problem is : your script has two different layers names : baseLayer and theLayer
Only one is needed : theLayer

Other details :
- None argument has to be passed to your script, so "construtor" is only the script name
- Undo group (start/end) is useful when a script modify an image, for image generator use undo (disable/enable)
- Indent with tabs instead of spaces
- Comment to explain what the code does

Have fun. Smile
@+++

Code:
; "New Image" image generator (new-image.scm)
; This script creates an image 500 x 500 filled with white background
; Pocholo
; 2020/04/19
;

(define (script-fu-new-image)
    (let* (
        (theImage  (car (gimp-image-new 500 500 RGB)))
        (theLayer (car (gimp-layer-new theImage 500 500 RGB-IMAGE "Wood" 100 LAYER-MODE-NORMAL)))
       )

        (gimp-image-undo-disable theImage)    ; Disable undo during the image creation

        (gimp-image-insert-layer theImage theLayer 0 0)
        (gimp-drawable-fill theLayer FILL-WHITE)
        (gimp-display-new theImage)

        (gimp-image-undo-enable theImage)    ; Enable undo for future modifications
    )
)

(script-fu-register
   "script-fu-new-image"                        
   "<Image>/File/Create/New image..."
    "Creates a New image"    
    "Pocholo"                            
    "Pocholo"
    "March 2020"                          
    ""
)
Reply
#4
(04-19-2020, 07:44 AM)JimmyMarco Wrote: - Indent with tabs instead of spaces

In 2020, your editor takes care of that. I use a tab key, and the editor puts spaces, if fact the editor handles the indentation. Tabs don't survive long in non-programming editors, and if you copy/paste code with tabs here it can get mangled.
Reply
#5
Hi everyone,  I hope everything is fine and your family, be safe. I want to thank you for your respond @ the Gimp-forum.net. You explained in simple ways how to write a GIMP script to an old man that is trying to learn at this age, the script-fu world [Image: hihi.gif] .

I created my first script out a tutorial I found in deviantart.com called "Create a seamless Wood Slat Pattern with GIMP 2.10" by Conbagui. I almost done with the script, but I have an error "unbound variable: drawable" when the "plug-in-make-seamless" runs. What am I missing? I uploaded the image and the code. Thank you once again.

https://imgur.com/kKnzQOC



Code:
; following steps in seamless Wood Slat Pattern tutorial by conbagui
; found at link:http://fav.me/ddss6bx
; author: conbagui
; date: 4/20/20

(define (script-fu-seamless-wood-slat-pattern)
   (let* (
       (theImage  (car (gimp-image-new 500 500 RGB)))
       (theLayer (car (gimp-layer-new theImage 500 500 RGB-IMAGE "Wood" 100 LAYER-MODE-NORMAL)))
        (theDesign (car (gimp-layer-new theImage 500 500 RGB "Design" 100 LAYER-MODE-NORMAL)))
        (theDivisions (car (gimp-layer-new theImage 500 500 RGB "theDivisions" 100 LAYER-MODE-NORMAL)))
        )
        ;create the image,
       (gimp-image-undo-disable theImage)    ; Disable undo during the image creation
       (gimp-image-insert-layer theImage theLayer 0 0)
       (gimp-drawable-fill theLayer FILL-WHITE)
       (gimp-display-new theImage)
        
        ;set the fg and bg colors,
        (gimp-context-set-foreground '(232 195 151))
        (gimp-context-set-background '(184 137 82))
        (gimp-context-set-gradient-fg-bg-rgb)
        
        ;add plasma2 and create wood design
        (plug-in-plasma2  RUN-NONINTERACTIVE theImage theLayer 16 0 0 0 0 0.00 1.00 2 "FG to BG")
        (plug-in-ripple RUN-NONINTERACTIVE theImage theLayer 320 800 0 1 1 TRUE TRUE)
       
        ;rotate the layer
        (gimp-image-rotate theImage ROTATE-90)
        (gimp-context-set-foreground '(191 164 132))
        
        ;add new layer
        (gimp-image-add-layer theImage theDesign -1)
        (gimp-drawable-fill theDesign FILL-FOREGROUND)
        (gimp-layer-set-mode theDesign LAYER-MODE-OVERLAY)
        (plug-in-hsv-noise RUN-NONINTERACTIVE theImage theDesign 8 2 4 255)
        (plug-in-wind RUN-NONINTERACTIVE theImage theDesign 15 2 45 0 0)
        (plug-in-wind RUN-NONINTERACTIVE theImage theDesign 15 3 45 0 0)
        (gimp-image-merge-down theImage theDesign 1)
        (plug-in-make-seamless RUN-NONINTERACTIVE theImage drawable)

           
               (gimp-image-undo-enable theImage)    ; Enable undo for future modifications

    )
         
   
)

(script-fu-register
   "script-fu-seamless-wood-slat-pattern"                        
   "<Image>/File/Create/Seamless wood slat pattern..."
    "Creates a wood pattern"    
    "Pocholo"                            
    "Pocholo"
    "March 2020"                          
    ""
)
Reply
#6
A parameter of your call is a drawable variable from the 7th dimension, it should be instead one of your existing drawables/layers (he one with the final design, likely).
Reply
#7
When you do gimp-image-merge-down it creates a new layer, so you need to find out what this is so it can be passed to plug-in-make-seamless.

For example I re-used theLayer as it doesn't exist after the merge down:
Code:
(set! theLayer (car (gimp-image-merge-down theImage theDesign 1)))
       (plug-in-make-seamless RUN-NONINTERACTIVE theImage theLayer)
       (gimp-displays-flush)
I also added the gimp-displays-flush so that it displayed the results so far.
Reply
#8
Thank you everyone, for all the pointers and explanations. You guys are awesome!  Smile
Reply


Forum Jump: