This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-02-26 19:22:08

t-boy
Scratcher
Registered: 2008-05-15
Posts: 21

Help with resurrecting an "obsolete" block?

I was browsing through the block methods today and under the pen ops i found a really interesting method that didnt have a block in scratch, i thought it was obsolete but it wasnt in the obsolete block class. it almost seems undiscovered because ive searched everywhere on the forums and no one has mentioned it. the name of it is
setPenColorFromCostumeNamed: t1 x: t2 y: t3
judging from the code and the title, it sets the pen color to the color value at point x,y on a desired costume. This to me could be really useful, i was thinking about making a security detector in Panther that would scan for color changes in a webcam snapshot to determine if there is activity/movement. the problem is that i have no idea how to correctly write the code for it in the block specs. I know how to make special blocks that do nothing (hence my username picture) but this is different, everything i tried wont work, but it functions perfectly at giving me error messages.
this is what i tried:
('set pen color from costume %l at x: %n y: %n' -# #setPenColorFromCostumeNamed: 50 50)
i dont know what im doing wrong, maybe its something about the 50 50 stuff or something else altogether.
please help if you can, you can find the method under
Scratch-Objects/ScratchSpriteMorph/pen ops/setPenColorFromCostumeNamed: in the system browser
thanks

Offline

 

#2 2012-02-26 19:35:40

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Help with resurrecting an "obsolete" block?

Try this:

('set pen color from costume at x:%n y:%n' -  setPenColorFromCostumeNamed: 0 0)


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#3 2012-02-26 19:59:50

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Help with resurrecting an "obsolete" block?

You need to use the whole selector:
('set pen color from costume %l at x: %n y: %n' -# #setPenColorFromCostumeNamed:x:y: 'costume1' 0 0)


nXIII

Offline

 

#4 2012-02-27 16:31:31

t-boy
Scratcher
Registered: 2008-05-15
Posts: 21

Re: Help with resurrecting an "obsolete" block?

bobbybee wrote:

Try this:

('set pen color from costume at x:%n y:%n' -  setPenColorFromCostumeNamed: 0 0)

thats missing a %l costume selection field

Offline

 

#5 2012-02-27 16:37:03

t-boy
Scratcher
Registered: 2008-05-15
Posts: 21

Re: Help with resurrecting an "obsolete" block?

nXIII wrote:

You need to use the whole selector:
('set pen color from costume %l at x: %n y: %n' -# #setPenColorFromCostumeNamed:x:y: 'costume1' 0 0)

huh, this also seems right but it gave an error, i tried it on both blockspec libraries with no luck... could it be the code itself?
here is the code for the method, does it look like there are any errors?
setPenColorFromCostumedNamed: t1 x: t2 y: t3
    | t4 t5 t6 t7 |
    t4 _ t1.
    t4 isNumber ifTrue: [t4 _ self costumeNameFromNumber: t1].
    t5 _ media
                detect: [:t8 | t8 isSound not and: [t8 mediaName caseInsensitiveEqual: t4]]
                ifNone: [^ self].
    t6 _ t5 form.
    t6 unhibernate.
    t7 _ ScratchPlugin
                primInterpolate: t6 bits
                width: t6 width
                x: (t2 * 1024) rounded
                y: (t6 height - t3 * 1024) rounded.
    t7 = 0
        ifTrue: [self penColor: Color black]
        ifFalse: [self penColor: (Color colorFromPixelValue: t7 depth: 24)]

Offline

 

#6 2012-02-27 16:40:28

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Help with resurrecting an "obsolete" block?

I doubt that it's the code that is the problem. By the way, this goes in the block specs for ScratchSpriteMorph...


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#7 2012-02-27 16:46:30

t-boy
Scratcher
Registered: 2008-05-15
Posts: 21

Re: Help with resurrecting an "obsolete" block?

yea i tried that. and just to make sure i tried it under scriptable and stage to but none of them work, it doesnt make any sense!

Offline

 

#8 2012-02-27 16:50:24

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Help with resurrecting an "obsolete" block?

Sorry--I'm not great at Squeak...


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#9 2012-02-27 16:56:29

t-boy
Scratcher
Registered: 2008-05-15
Posts: 21

Re: Help with resurrecting an "obsolete" block?

haha well youre better than me. maybe nxlll will know what to do, didnt he like made panther?

Offline

 

#10 2012-02-27 17:02:31

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Help with resurrecting an "obsolete" block?

Not like made panther: did make panther (for the most part any, way)


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#11 2012-02-27 17:15:14

t-boy
Scratcher
Registered: 2008-05-15
Posts: 21

Re: Help with resurrecting an "obsolete" block?

wow thats amazing, hes already making mods and is only in his teens (i suspect). I wish i knew some actual languages, as of now im just to lazy :P

Offline

 

#12 2012-02-27 17:57:53

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Help with resurrecting an "obsolete" block?

t-boy wrote:

nXIII wrote:

You need to use the whole selector:
('set pen color from costume %l at x: %n y: %n' -# #setPenColorFromCostumeNamed:x:y: 'costume1' 0 0)

huh, this also seems right but it gave an error, i tried it on both blockspec libraries with no luck... could it be the code itself?
here is the code for the method, does it look like there are any errors?

Ha, sorry, the method name is actually spelled incorrectly. It should be ('set pen color from costume %l at x: %n y: %n' -# #setPenColorFromCostumedNamed:x:y: 'costume1' 0 0)


nXIII

Offline

 

#13 2012-02-27 19:18:29

t-boy
Scratcher
Registered: 2008-05-15
Posts: 21

Re: Help with resurrecting an "obsolete" block?

this works great. crazy how a single letter can keep everything from working haha.

Offline

 

Board footer