It is currently Tue Jul 02, 2024 4:42 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Script writer newbie
PostPosted: Sat Feb 08, 2020 2:39 pm  (#1) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
Hi everyone! I'm trying to learn how to write scripts and I'm going through the basics. I'm trying to create a simple "Slider" dialog that will create a New image. But when I'm trying to run it, it's giving me an error. Can any experience coder here explain what am I doing wrong?

"Error while executing script-fu-new-layer-white:
Error: eval: unbound variable: image"

This is what the script looks like:

(define (script-fu-new-layer-white)
   (gimp-image-new 400 400 GRAY)
   (gimp-layer-new image 400 400 GRAY-IMAGE "New" 100 LAYER-MODE-NORMAL)
   (gimp-image-insert-layer image layer 0 0)
   (gimp-drawable-fill layer FILL-WHITE)
   (gimp-display-new image)
   
)   
   
(script-fu-register   
   "script-fu-new-layer-white"
   "<Image>/Files/Create/New layer"
   "Generates a New layer"
   "Pocholo"
   "Pocholo"
   "Feb 2020"
   ""
   SF-ADJUSTMENT "Layer Size (px)" '(400 1200 1 10 0 SF-SLIDER)

_________________
https://www.deviantart.com/pocholo17
Image


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Script writer newbie
PostPosted: Sat Feb 08, 2020 7:16 pm  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4752
Pocholo wrote:
I'm trying to learn how to write scripts


So you should really use Python instead. Much easier to learn.

This said, looking at your code, gimp-image-new and gimp-layer-new both return the id of the created image layer, so you have to keep these somewhere to be able to reuse them in the following function calls.

_________________
Image


Top
 Post subject: Re: Script writer newbie
PostPosted: Sat Feb 08, 2020 11:49 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: Jan 13, 2011
Posts: 2260
Location: Poland
Hi Pocholo.

Did Ofnuts' comments help?
If not - see for example:
(define (script-fu-new-layer-white size)

   (let*(
       (image (car (gimp-image-new size size GRAY)))
       (test (car (gimp-layer-new image size size GRAY-IMAGE "New" 100 LAYER-MODE-NORMAL)))
         )
   (gimp-image-insert-layer image test 0 0)
   (gimp-drawable-fill test FILL-WHITE)
   (gimp-display-new image)
    )
)
(script-fu-register
   "script-fu-new-layer-white"
   "<Image>/File/Create/New layer..."
   "Generates a New layer"
   "Pocholo"
   "Pocholo"
   "Feb 2020"
   ""
   SF-ADJUSTMENT "Layer Size (px)" '(400 1 1200 1 10 0 SF-SLIDER)


And three more comments:
1. If you enter the selection parameter (SF-ADJUSTMENT) must be defined.
2. SF-ADJUSTMENT "Layer Size (px)" '(400 1200 1 10 0 SF-SLIDER) requires 7 arguments (not 6)
3. Location on the menu is probably:
"<Image>/File/Create/New layer..." (not Files)

Python basics are probably easier to learn (and only this has a future...)
Good luck in Your studies :jumpclap

_________________
Image

Slava
Ukraini!


Top
 Post subject: Re: Script writer newbie
PostPosted: Sun Feb 09, 2020 1:36 am  (#4) 
Offline
GimpChat Member

Joined: Jul 28, 2018
Posts: 1196
@ ofnuts: Thank you so much for the advise! I will give it a try at python scripting.

@MareroQ: Thank you for the fixing!
You guys are awesome! :jumpclap :tyspin

_________________
https://www.deviantart.com/pocholo17
Image


Top
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts GIMP newbie with problems

3

No new posts Attachment(s) GIMP newbie, trying to create a fuzzy border on a gif with 383 frames

2

No new posts Newbie alert: loading numbered files for G'MIC transformation

5

No new posts Attachment(s) Looking for Script Coder to make Script of my VHS effect

2

No new posts Attachment(s) Cannot run test script-fu script via console

7



* Login  



Powered by phpBB3 © phpBB Group