These some of the new blocks that I will explane how to make..
.....for these tuitorials I will be using SCRATCH 1.4, I recomend using the SCRATCH 1.4 source code..... You can find it here
First I will explane the |setVar %v to %s if %b else %s| block...
First lets start out with the CLASS part of block... for those who dont know how to get there, just open up the browser and follow this path Scratch-Objects/ScriptableScratchMorph/switch over to the class side/block Specs/blockSpecs. now go down to where it says 'variables' at the bottom of all the code. now type this in right after where it says 'variables'
('setVar %v to%s if %b else %s' #- #setVar:to:if:else:)now go and switch to the instances panel/ then select other ops .. now in the window below, please erase all the text that is there right now and type in
setVar: varName to: newValue if: t1 else: t2
| vName stage |
vName _ varName asString. "convert Symbol to String if needed"
(vars includesKey: vName) ifFalse: [
stage _ self ownerThatIsA: ScratchStageMorph.
(stage notNil and: [stage ~= self] ). (t1 = true)
ifTrue: [stage setVar: varName to: newValue]
ifFalse: [stage setVar: varName to: t2].
^ self].
vars at: vName put: newValue.and now you have a new setVar block!
here is a quick tuitorial I copied from LS97
('repeat %n' #c #doRepeat 10)
the block is identified by the two brackets (blue).
the block text is in between apostrophes (black).
the block type identifier or block arguments follow a # sign (red).
the command also follows a # sign (green).
any additional arguments follow the command (purple).
the %n in the block is the input box, where the user can put the number. in fact, %n produces that round textbox where only numbers can be inserted. here's the full list:Code:
a: attribute of another sprite, such as X position or size.
b: a boolean inserter
c: a colour picker that shows the menu.
C: a colour picker that doesn't
d: the sprite direction menu/numerical inserter.
D: the menu for midi drums
e: The broadcast message menu
f: math function menu (with sin, abs, etc.)
g: menu for the different graphic effects.
h: numerical sensor board selector menu
H: boolean sensor board selector menu
i: midi instrument menu/numerical inserter
k: menu for the names of the different keys, used in the key sensor blocks.
l: menu with the costume names of the given sprite.
L: list name menu.
m: sprite list
n: numerical inserter
N: note name menu/inserter
s: string inserter
S: sound selector menu
v: variable labels menu
y: menu used to delete either a number of the last value or all of a list.Credit to billyedward for this list.
the repeat block, having to 'host' other blocks in it, is C shaped. that's why the block argument (above in red) is a c.
Here's a brief list of the different arguments:Code:
#- no arguments (command or 'stack' block)
#r Reporter block (the round ones)
#b boolean block (diamond shaped)
#c C shaped block (like the forever block)
#t Time block (like wait X secs)
#W 'when' hat block (obsolete)
#S start button click hat block
#K key-activated hat block
#E event hat block (broadcast)
#s special form (hard to code)
I will suply tuitorials for the |delete file $String$| and the |make new file $String$| blocks and for more custom blocks later. In the meen time, feel free to comment on or sudjest blocks. Also, please feel free to share your own custom blocks
(since these blocks were made and only work in panther, and since panther use 2 $ signs with an argument inside you must right $String$ not %s ($String$ is used with panther and %s works with scratch, both meen the same thing but the %s must not be used in panther and the $String$ cant be used in scratch)
UPDATE::: ::::::::::: :::::::::::::: ::::::::::::: :::::::::::::: :::::::::::::::: ::::::::::::: :::::::::::: ok!! now i will discuss how to make the |Make file $String$| block. This block must be written in panther for it to work. Since we are working in panther we use $String$ instead of %s. ok. so here is the CLASS part of the code
('make new file $String$' - createFile:)now to explane
the - symbol makes the custom block a regular square block.
the 'make new file $String$' is the text the user will seep
now we will switch over to the instance side and click on -- other ops -- and erase all the text in the window below. now type
createFile: aFileNameString
"Create the given file."
| f |
(self askForFileIO = true) ifFalse: [^ self].
f _ FileStream newFileNamed: aFileNameString.
f closeUPDATE :::::::::: :::::::::: ::::::::::::::::: :::::::::::::::: ::::::::::::!:!:!:!:!:! : ::::::::::::::::
Now for the................|DELETE FILE $String$| block. as i said above
Since we are working in panther we use $String$ instead of %s.
now this block must be used in panther only because, as nXIII said,
The reason file I/O blocks won't work is the "self askForFileIO" line, which throws an error if "askForFileIO" is not defined in ScriptableScratchMorph.
now!!! here is the CLASS part of the code
with panther source code
Code:
('delete file $String$' - deleteFile:)
.
without panther source code
Code:
('delete file $String$' #- #deleteFile:)
in regular panther (and also in scratch you must use # signs before the - sign and
deleteFile:
now for the INSTANCES part of the code
deleteFile: aFileNameString
| dir |
self askForFileIO = true ifFalse: [^ self].
dir _ FileDirectory forFileName: aFileNameString.
dir deleteFileNamed: aFileNameStringLast edited by brantsmith (2010-10-15 20:19:01)

Offline
This is a nice thread, but perhapse it is more of a tutorial to make this one block than to make blocks yourself, and there are already several block tutorials/libraries out there.
it might be worth explaining, as I have seen this seriously confuse some people, that Scratch uses % symbols with one following character whilst Panther uses two $'s with an argument in between. I have actually seen someone type block code that contained %n and $String$ in the same block O_o
Offline
brantsmith wrote:
These some of the new blocks that I will explane how to make..http://gbryouth.webstarts.com/uploads/scratch_forum.jpg
.....for these tuitorials I will be using SCRATCH 1.4, I recomend using the SCRATCH 1.4 source code..... You can find it here
First I will explane the |setVar %v to %s if %b else %s| block...
First lets start out with the CLASS part of block... for those who dont know how to get there, just open up the browser and follow this path Scratch-Objects/ScriptableScratchMorph/switch over to the class side/block Specs/blockSpecs. now go down to where it says 'variables' at the bottom of all the code. now type this in right after where it says 'variables'Code:
('setVar %v to%s if %b else %s' #- #setVar:to:if:else:)now go and switch to the instances panel/ then select other ops .. now in the window below, please erase all the text that is there right now and type in
Code:
setVar: varName to: newValue if: t1 else: t2 | vName stage | vName _ varName asString. "convert Symbol to String if needed" (vars includesKey: vName) ifFalse: [ stage _ self ownerThatIsA: ScratchStageMorph. (stage notNil and: [stage ~= self] ). (t1 = true) ifTrue: [stage setVar: varName to: newValue] ifFalse: [stage setVar: varName to: t2]. ^ self]. vars at: vName put: newValue.and now you have a new setVar block!
here is a quick tuitorial I copied from LS97('repeat %n' #c #doRepeat 10)
the block is identified by the two brackets (blue).
the block text is in between apostrophes (black).
the block type identifier or block arguments follow a # sign (red).
the command also follows a # sign (green).
any additional arguments follow the command (purple).
the %n in the block is the input box, where the user can put the number. in fact, %n produces that round textbox where only numbers can be inserted. here's the full list:Code:
a: attribute of another sprite, such as X position or size.
b: a boolean inserter
c: a colour picker that shows the menu.
C: a colour picker that doesn't
d: the sprite direction menu/numerical inserter.
D: the menu for midi drums
e: The broadcast message menu
f: math function menu (with sin, abs, etc.)
g: menu for the different graphic effects.
h: numerical sensor board selector menu
H: boolean sensor board selector menu
i: midi instrument menu/numerical inserter
k: menu for the names of the different keys, used in the key sensor blocks.
l: menu with the costume names of the given sprite.
L: list name menu.
m: sprite list
n: numerical inserter
N: note name menu/inserter
s: string inserter
S: sound selector menu
v: variable labels menu
y: menu used to delete either a number of the last value or all of a list.Credit to billyedward for this list.
the repeat block, having to 'host' other blocks in it, is C shaped. that's why the block argument (above in red) is a c.
Here's a brief list of the different arguments:Code:
#- no arguments (command or 'stack' block)
#r Reporter block (the round ones)
#b boolean block (diamond shaped)
#c C shaped block (like the forever block)
#t Time block (like wait X secs)
#W 'when' hat block (obsolete)
#S start button click hat block
#K key-activated hat block
#E event hat block (broadcast)
#s special form (hard to code)I will suply tuitorials for the |delete file $String$| and the |make new file $String$| blocks and for more custom blocks later. In the meen time, feel free to comment on or sudjest blocks. Also, please feel free to share your own custom blocks
Did you make the make new file and delete file blocks your self?
Offline
MarkyParky56------Yes, I did make the MAKE FILE $String$ and the DELETE FILE $String$ blocks... since these blocks must be used in panther for the coding to work, and since panther uses (as sparks commented) two $ signs with an argument in between, you must use $String$ not %s

Offline
brantsmith wrote:
MarkyParky56------Yes, I did make the MAKE FILE $String$ and the DELETE FILE $String$ blocks... since these blocks must be used in panther for the coding to work, and since panther uses (as sparks commented) two $ signs with an argument in between, you must use $String$ not %s
I was just wondering, and you don't need to tell me about how to code the blocks inputs, If you didn't know, I'm one of the panther devs.
Offline
markyparky56 wrote:
brantsmith wrote:
MarkyParky56------Yes, I did make the MAKE FILE $String$ and the DELETE FILE $String$ blocks... since these blocks must be used in panther for the coding to work, and since panther uses (as sparks commented) two $ signs with an argument in between, you must use $String$ not %s
I was just wondering, and you don't need to tell me about how to code the blocks inputs, If you didn't know, I'm one of the panther devs.
![]()
WOW!!! I LOVE PANTHER!!!!!! It is the best platform for developing scratch prodjects... I think I put the code on the forum on the panther website. I would LOVE if you could use the block in the next panther mod

Offline
brantsmith wrote:
markyparky56 wrote:
brantsmith wrote:
MarkyParky56------Yes, I did make the MAKE FILE $String$ and the DELETE FILE $String$ blocks... since these blocks must be used in panther for the coding to work, and since panther uses (as sparks commented) two $ signs with an argument in between, you must use $String$ not %s
I was just wondering, and you don't need to tell me about how to code the blocks inputs, If you didn't know, I'm one of the panther devs.
![]()
WOW!!! I LOVE PANTHER!!!!!! It is the best platform for developing scratch prodjects... I think I put the code on the forum on the panther website. I would LOVE if you could use the block in the next panther mod
Sparks is one aswell... He's making Blockshop which allows you to get free custom blocks donated by other users. Its going to be released along with the next version panther (1.1)
Offline
I'm a dev too!
Meh, a write file block wouldn't be good unless you could define a path to create it in, though.
Offline
SeptimusHeap wrote:
I'm a dev too!
Meh, a write file block wouldn't be good unless you could define a path to create it in, though.
right now, the way that the block is coded is that it writes the text file to the panther file. just like when you ask for the contents of file hi.txt the block automatically looks in the panther file to find the text file
Last edited by brantsmith (2010-07-07 09:36:16)

Offline
Well ive already done the make file and make file in location blocks so...
Offline
brantsmith wrote:
MarkyParky56------Yes, I did make the MAKE FILE $String$ and the DELETE FILE $String$ blocks... since these blocks must be used in panther for the coding to work, and since panther uses (as sparks commented) two $ signs with an argument in between, you must use $String$ not %s
I suppose I should explain why I changed this. Is it easy to tell that %W is a motor directions menu? Or %f is a math functions menu? Not really - that's why I changed the way the arguments are parsed so that multiple characters can be used. However, $Number$ is the EXACT same argument as %n (unless I changed it in Panther, but I don't think I did). The reason file I/O blocks won't work is the "self askForFileIO" line, which throws an error if "askForFileIO" is not defined in ScriptableScratchMorph.
Last edited by nXIII (2010-07-07 19:35:44)
Offline