nXIII wrote:
Jakey22 wrote:
Please do the dialog block next. Thanks!
Why are you asking for blocks with existing tutorials?
Where is the tutorial?
Last edited by Jakey22 (2010-04-19 19:45:57)
Offline
manuke wrote:
i would like a (touched color) block.
i would report the color that he's touching at the same scale as the block[blocks] <change[ ]effect by( [/blocks](scale 0-200)
That would not be possible as the sprite is more than one pixel, so the colors it is touching could be more than one. i can still try to make it work for a 1@1 sprite, but i can't guarantee any results.
EDIT: my knowledge does not go far enough for your block. i can't figure anything out.
Last edited by LS97 (2010-04-20 10:50:40)
Offline
LS97 wrote:
The link block
Ok, finally some time to add the greatest block of all. the block links the user to a webpage, program or file as long as the path or URL is given. add in the blockspecs in the control section some kind of block code (choose whatever you want, you know how to do it). and add in the corresponding instance ops:Code:
Cursor wait showWhile: [ScratchPlugin primOpenURL: t1]So little code for such a great block... and remember to click accept!
For people who aren't sure how to put this in the block specs, here's a good way:
('go to website %s' #- #getLink: 'http://scratch.mit.edu/')
The result will be a block that says "go to website [http://scratch.mit.edu/]" wherein scratch.mit.edu is what it says by default.
Offline
randalpik wrote:
LS97 wrote:
The link block
Ok, finally some time to add the greatest block of all. the block links the user to a webpage, program or file as long as the path or URL is given. add in the blockspecs in the control section some kind of block code (choose whatever you want, you know how to do it). and add in the corresponding instance ops:Code:
Cursor wait showWhile: [ScratchPlugin primOpenURL: t1]So little code for such a great block... and remember to click accept!
For people who aren't sure how to put this in the block specs, here's a good way:
Code:
('go to website %s' #- #getLink: 'http://scratch.mit.edu/')The result will be a block that says "go to website [http://scratch.mit.edu/]" wherein scratch.mit.edu is what it says by default.
That's a good block spec, but i would say 'link to' instead of 'go to site' because the block does not only link to sites but also to programs.
Offline
LS97 wrote:
manuke wrote:
i would like a (touched color) block.
i would report the color that he's touching at the same scale as the block[blocks] <change[ ]effect by( [/blocks](scale 0-200)That would not be possible as the sprite is more than one pixel, so the colors it is touching could be more than one. i can still try to make it work for a 1@1 sprite, but i can't guarantee any results.
EDIT: my knowledge does not go far enough for your block. i can't figure anything out.
well if you can do it for a 1@1 sprite i would like it very much and hope you can do it
Offline
LS97 wrote:
The 'showing?' block
This is an easy one. It gives a boolean response (True/False) of whether the sprite is showing or not.
Like before, copy this code into the 'looks' section of blockSpecs in ScratchSpriteMorphCode:
('showing?' #b #getHidden)then go to instance, 'looks ops' and replace the code in 'hide' with the code below (by the way, you're not deleting the hide block).
Code:
getHidden self isHidden = false ifTrue: [^ true]. ^ falseThen right-click, clik accept and (maybe) type your initials. et voilà, you have your 'showing?' block up and ready.
You can also get a "hidden?" block like this:
Go to the blockSpecs based on the instructions above (by ls97) and add this:
('hidden?' #b #getShowing)
Go to instance, click on "looks ops" and in the main screen add this code:
getShowing self isHidden = false ifTrue: [^ false]. ^ true
Hope that's helpful!
Offline
LS97 wrote:
randalpik wrote:
LS97 wrote:
The link block
Ok, finally some time to add the greatest block of all. the block links the user to a webpage, program or file as long as the path or URL is given. add in the blockspecs in the control section some kind of block code (choose whatever you want, you know how to do it). and add in the corresponding instance ops:Code:
Cursor wait showWhile: [ScratchPlugin primOpenURL: t1]So little code for such a great block... and remember to click accept!
For people who aren't sure how to put this in the block specs, here's a good way:
Code:
('go to website %s' #- #getLink: 'http://scratch.mit.edu/')The result will be a block that says "go to website [http://scratch.mit.edu/]" wherein scratch.mit.edu is what it says by default.
That's a good block spec, but i would say 'link to' instead of 'go to site' because the block does not only link to sites but also to programs.
That's true.
Offline
randalpik wrote:
LS97 wrote:
The 'showing?' block
This is an easy one. It gives a boolean response (True/False) of whether the sprite is showing or not.
Like before, copy this code into the 'looks' section of blockSpecs in ScratchSpriteMorphCode:
('showing?' #b #getHidden)then go to instance, 'looks ops' and replace the code in 'hide' with the code below (by the way, you're not deleting the hide block).
Code:
getHidden self isHidden = false ifTrue: [^ true]. ^ falseThen right-click, clik accept and (maybe) type your initials. et voilà, you have your 'showing?' block up and ready.
You can also get a "hidden?" block like this:
Go to the blockSpecs based on the instructions above (by ls97) and add this:Code:
('hidden?' #b #getShowing)Go to instance, click on "looks ops" and in the main screen add this code:
Code:
getShowing self isHidden = false ifTrue: [^ false]. ^ trueHope that's helpful!
Theres a easier way than that!
Just use ('Hidden?' #b #isHidden)
Offline
Sperry wrote:
randalpik wrote:
LS97 wrote:
The 'showing?' block
This is an easy one. It gives a boolean response (True/False) of whether the sprite is showing or not.
Like before, copy this code into the 'looks' section of blockSpecs in ScratchSpriteMorphCode:
('showing?' #b #getHidden)then go to instance, 'looks ops' and replace the code in 'hide' with the code below (by the way, you're not deleting the hide block).
Code:
getHidden self isHidden = false ifTrue: [^ true]. ^ falseThen right-click, clik accept and (maybe) type your initials. et voilà, you have your 'showing?' block up and ready.
You can also get a "hidden?" block like this:
Go to the blockSpecs based on the instructions above (by ls97) and add this:Code:
('hidden?' #b #getShowing)Go to instance, click on "looks ops" and in the main screen add this code:
Code:
getShowing self isHidden = false ifTrue: [^ false]. ^ trueHope that's helpful!
Theres a easier way than that!
Just use ('Hidden?' #b #isHidden)
*Facepalm* I should have thought of that.
Offline
Sperry wrote:
Theres a easier way than that!
Just use ('Hidden?' #b #isHidden)
Yeah i know but as the red note in the first post says, this is a tutorial and somewhat going into the code further encourages learning.
Offline
I now found out the code for "import image and wait"!
It's exactly as easy as the "save stage area to sprite" block.
All you have to do is add this in the looks section ofScratchSpriteMorph --> block specs --> blockSpecs:
('import image and wait' #- #importImage)
And that's it!
Offline
randalpik wrote:
I now found out the code for "import image and wait"!
It's exactly as easy as the "save stage area to sprite" block.
All you have to do is add this in the looks section ofScratchSpriteMorph --> block specs --> blockSpecs:
('import image and wait' #- #importImage)
And that's it!
yup! thanks for adding a block tutorial you saved me a post
Offline
Ok, I got 2 more blocks.
Make a Variable- makes a variable and asks you for the name while a program is running. Doesn't work in Presentation mode.
All you have to do is type this in the operators section of ScriptableScratchMorph--> block specs--> blockSpecs:
('make a variable' #- #addGlobalVariable)
Draw New Costume- Opens up a paint editor for you to draw a new costume while the program is running.
All you have to do is type this in the looks section of ScratchSpriteMorph--> block specs--> blockSpecs:
('draw new costume' #- #drawNewCostume)
this is fun, exposing LS97's ideas XD (jk)
EDIT: I can't seem to make a "clone" block work, can anyone help?
Last edited by randalpik (2010-04-20 12:57:23)
Offline
randalpik wrote:
EDIT: I can't seem to make a "clone" block work, can anyone help?
it's simple!
add this code:
cloneAndSend: t1 | t2 t3 | (t2 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self]. t3 _ self fullCopy. t3 objName: objName , ' clone'. t3 isClone: true. t3 blocksBin allMorphsDo: [:t4 | (t4 isKindOf: BlockMorph) ifTrue: [t4 stop]]. t2 workPane addMorph: t3. t3 eventReceived: (ScratchEvent new name: t1 asString argument: 0)
i'm not sure though
Offline
LS97 wrote:
randalpik wrote:
EDIT: I can't seem to make a "clone" block work, can anyone help?
it's simple!
add this code:Code:
cloneAndSend: t1 | t2 t3 | (t2 _ self ownerThatIsA: ScratchFrameMorph) ifNil: [^ self]. t3 _ self fullCopy. t3 objName: objName , ' clone'. t3 isClone: true. t3 blocksBin allMorphsDo: [:t4 | (t4 isKindOf: BlockMorph) ifTrue: [t4 stop]]. t2 workPane addMorph: t3. t3 eventReceived: (ScratchEvent new name: t1 asString argument: 0)i'm not sure though
That's already in ScratchSpriteMorph. Besides, it says "incorrect number of arguments."
Offline
hmm dosent work me when i get on to scriptablescratchmorph bit it comes up with intilization, accessing, look ops, sound ops, sensing ops, list ops, string ops, motor ops, other ops, variables, scripts, blocks and a whole loadf of other stuff
Offline
Cloning blocks:
(yay, I made these)
Somewhat simplified because you don't have to send it an event, like Panther.
cloneMe
| frame stage clone |
(frame _ self ownerThatIsA: ScratchFrameMorph) ifNil: [(frame _ self ownerThatIsA: OffscreenWorldMorph) ifNil: [^ self] ifNotNil: [frame _ frame frame]].
stage _ frame workPane.
clone _ self fullCopy.
clone objName: (self objName), ' clone'.
stage addMorphFront: clone.
If you want to send it a broadcast message, add the line
clone eventReceived: 'Created'.
to the end and if the sprite has a 'when I receive [Created]' that will start (in the clone) when it is cloned.
It might not work, I did that off of memory, not copy-paste. (This isn't my computer)
Last edited by nXIII (2010-04-20 13:45:26)
Offline
nXIII wrote:
Cloning blocks:
(yay, I made these)
Somewhat simplified because you don't have to send it an event, like Panther.cloneMe
| frame stage clone |
(frame _ self ownerThatIsA: ScratchFrameMorph) ifNil: [(frame _ self ownerThatIsA: OffscreenWorldMorph) ifNil: [^ self] ifNotNil: [frame _ frame frame]].
stage _ frame workPane.
clone _ self fullCopy.
clone objName: (self objName), ' clone'.
stage addMorphFront: clone.If you want to send it a broadcast message, add the line
clone eventReceived: 'Created'.
to the end and if the sprite has a 'when I receive [Created]' that will start (in the clone) when it is cloned.
It might not work, I did that off of memory, not copy-paste. (This isn't my computer)
That means it clones in Presentation mode doesn't it?
Offline
nXIII wrote:
Cloning blocks:
(yay, I made these)
Somewhat simplified because you don't have to send it an event, like Panther.cloneMe
| frame stage clone |
(frame _ self ownerThatIsA: ScratchFrameMorph) ifNil: [(frame _ self ownerThatIsA: OffscreenWorldMorph) ifNil: [^ self] ifNotNil: [frame _ frame frame]].
stage _ frame workPane.
clone _ self fullCopy.
clone objName: (self objName), ' clone'.
stage addMorphFront: clone.If you want to send it a broadcast message, add the line
clone eventReceived: 'Created'.
to the end and if the sprite has a 'when I receive [Created]' that will start (in the clone) when it is cloned.
It might not work, I did that off of memory, not copy-paste. (This isn't my computer)
Nope, doesn't work. gives me an error message about the incorrect number of arguments or something...
Offline
Offline
rocket101 wrote:
Nice guide, LS97!
thanks rocket101! i'm glad you like it and enjoy your new blocks.
Offline