Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » M30W - Code Scratch with Scratchblocks!
- Magnie
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
The syntax highlighting should be the original blocks. xD
▴ ▾ ▴ Macbook Pro 13" 2015 i5-5257U 8GB RAM - MacOS Sierra - Vivaldi v1.7 ▴ ▾ ▴
There are 10 types of people in this world, those who understand binary, those who don't, and those who know ternary.
- davidkt
- Scratcher
1000+ posts
M30W - Code Scratch with Scratchblocks!
? The syntax highlighting should be the original blocks. xD
Remember when I looked like this? I still do.
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
- Magnie
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
Have the actual blocks be displayed in the background when typing them in.? The syntax highlighting should be the original blocks. xD
▴ ▾ ▴ Macbook Pro 13" 2015 i5-5257U 8GB RAM - MacOS Sierra - Vivaldi v1.7 ▴ ▾ ▴
There are 10 types of people in this world, those who understand binary, those who don't, and those who know ternary.
- davidkt
- Scratcher
1000+ posts
M30W - Code Scratch with Scratchblocks!
Oh. But shouldn't we have a beginner + advanced mode, having the beginner mode with the suggested highlighting and the scratchblocks syntax, and the advanced mode colour-coded and an alternate syntax?Have the actual blocks be displayed in the background when typing them in.? The syntax highlighting should be the original blocks. xD
Remember when I looked like this? I still do.
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
- Magnie
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
Only if you are willing to program it, otherwise I would suggest sticking with one or the other.Oh. But shouldn't we have a beginner + advanced mode, having the beginner mode with the suggested highlighting and the scratchblocks syntax, and the advanced mode colour-coded and an alternate syntax?Have the actual blocks be displayed in the background when typing them in.? The syntax highlighting should be the original blocks. xD
▴ ▾ ▴ Macbook Pro 13" 2015 i5-5257U 8GB RAM - MacOS Sierra - Vivaldi v1.7 ▴ ▾ ▴
There are 10 types of people in this world, those who understand binary, those who don't, and those who know ternary.
- roijac
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
Hey, that's a really good idea, actually, and I don't plan on doing it either, so why not take it on yourself? Replace the wx.TextCtrl with something more appropriate for coding. Something like StyledTextControl would be great
Example of use for python here
Example of use for python here
Last edited by roijac (July 7, 2013 19:15:59)
- davidkt
- Scratcher
1000+ posts
M30W - Code Scratch with Scratchblocks!
Example use of alternate syntax:
event on_GF_Click {
say("Hello World!");
repeat(10) {
moveSteps(10);
turnCW(15);
//This is a comment
penDown();
chgX(42);
var foo = 128;
chgY(foo);
penUp();
}
think("That's all folks!");
say("BTW: Eat At Joe's!", secs = 2);
}
Last edited by davidkt (July 7, 2013 22:47:00)
Remember when I looked like this? I still do.
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
- roijac
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
No! Example use of alternate syntax:event on_GF_Click {
say("Hello World!");
repeat(10) {
moveSteps(10);
turnCW(15);
//This is a comment
penDown();
chgX(42);
var foo = 128;
chgY(foo);
penUp();
}
think("That's all folks!");
say("BTW: Eat At Joe's!", secs = 2);
}
No curly brackets or semicolons for God's sake!
Now, seriously, these two unnecessary elements are so error-prone that I'm against anything that uses it.
And:
- We don't init vars inside code in Scratch
- The terminology ‘event’ is not used in Scratch. What's bad about ‘when gf clicked’ like users would expect it?
- Cryptic abbreviations like chg don't help users guess what it means.
- Having to indent every line is pretty redundant
- Stay close to the Scratch blocks - special casing say(message, secs=-1) sure doesn't make parsing easier.
I beg to differ:
when gf clicked
say "Hello World!"
repeat 10
move 10 steps
turn cw 15 degrees // Comments
pen down
change X by 42
set [foo] to 128
change Y by foo
end
think "That's all folks!"
say "BTW: Eat At Joe's!" for 2 secs
- davidkt
- Scratcher
1000+ posts
M30W - Code Scratch with Scratchblocks!
Ok… I don't like that either, let's not put it in. We don't init vars inside code in Scratch
The terminology ‘event’ is not used in Scratch. What's bad about ‘when gf clicked’ like users would expect it?There is a new category called Event…
Cryptic abbreviations like chg don't help users guess what it means.If you're an experienced programmer and are in advanced mode, then chances are, you'll know what it means.
Having to indent every line is pretty redundantAUTOMATIC INDENTER!!!!!!!!!!!!!!! LIKE EVERY LEGITIMATE IDE!!!
Stay close to the Scratch blocks - special casing say(message, secs=-1) sure doesn't make parsing easier.Well, this will be easier to translate other languages to, say, Java, Python, C, C++, Actionscript, JavaScript, C#, etc… I'm willing to write that code, if you want…
I beg to differ:You don't have to use advanced mode…when gf clicked
say "Hello World!"
repeat 10
move 10 steps
turn cw 15 degrees // Comments
pen down
change X by 42
set [foo] to 128
change Y by foo
end
think "That's all folks!"
say "BTW: Eat At Joe's!" for 2 secs
Remember when I looked like this? I still do.
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
- roijac
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
Sorry about the events, I forgot the did change it back from triggers to events
Now I understood you, you want to make sort of an ‘advanced mode’, right? But as long it doesn't have any advantages other than syntax I don't see the point of maintaining the two. I would really prefer to come to an agreement
About the indentation: Of course you can code an auto-indenter, but it still seems to me redundant. If we don't have reasons to code something extra, then why should we? And it doesn't correlate to the Scratch way of displaying blocks.
Well, this will be easier to translate other languages to, say, Java, Python, C, C++, Actionscript, JavaScript, C#, etc… I'm willing to write that code, if you want…But it can't be translated easily because the GUI and the execution engine are already a big chunk of code. The only thing we want to translate to is Scratch (and, perhaps, Snap!). This argument is invalid
Now I understood you, you want to make sort of an ‘advanced mode’, right? But as long it doesn't have any advantages other than syntax I don't see the point of maintaining the two. I would really prefer to come to an agreement
About the indentation: Of course you can code an auto-indenter, but it still seems to me redundant. If we don't have reasons to code something extra, then why should we? And it doesn't correlate to the Scratch way of displaying blocks.
- blob8108
- Scratcher
1000+ posts
M30W - Code Scratch with Scratchblocks!
I'm going to side with roijac here. And as M30W uses Kurt's parser anyhow, I don't think the argument matters (though of course you could write your own if you so wished).
I've nearly finished writing a new parser for Kurt 2, inspired by nXIII's one, that doesn't require excessive parentheses. It's based on the design of the Pratt parser that nXIII linked.
Here's it parsing the script roijac posted:
Note that the variable “foo” has been defined on the Stage beforehand. Kurt 2 has a built-in way of getting the options to a menu insert, by using Insert.options().
Something more complicated:
I've nearly finished writing a new parser for Kurt 2, inspired by nXIII's one, that doesn't require excessive parentheses. It's based on the design of the Pratt parser that nXIII linked.
Here's it parsing the script roijac posted:
In [1]: p.stage.parse("""when gf clicked say "Hello World!" repeat 10 move 10 steps turn cw 15 degrees pen down change x by 42 set foo to 128 change y by foo end think "That's all folks!" say "BTW: Eat At Joe's!" for 2 secs""") In [2]: p.stage.scripts[0] Out[2]: kurt.Script([ kurt.Block('whenGreenFlag'), kurt.Block('say:', 'Hello World!'), kurt.Block('doRepeat', 10, [ kurt.Block('forward:', 10), kurt.Block('turnRight:', 15), kurt.Block('putPenDown'), kurt.Block('changeXposBy:', 42), kurt.Block('setVar:to:', 'foo', 128), kurt.Block('changeYposBy:', kurt.Block('readVariable', 'foo'), ), ]), kurt.Block('think:', "That's all folks!"), kurt.Block('say:duration:elapsed:from:', "BTW: Eat At Joe's!", 2)]) In [3]: print p.stage.scripts[0].stringify() when @greenFlag clicked say 'Hello World!' repeat 10 move 10 steps turn @turnRight 15 degrees pen down change x by 42 set foo to 128 change y by (foo) end think "That's all folks!" say "BTW: Eat At Joe's!" for 2 secs
Something more complicated:
In [2]: parsec("set foo to item 2 + 3 * 4 of positions + 10").stringify() Out[2]: u'set foo to ((item (2 + (3 * 4)) of positions) + 10)'
- roijac
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
Looks great! I'm going to side with roijac here. And as M30W uses Kurt's parser anyhow, I don't think the argument matters (though of course you could write your own if you so wished).
I've nearly finished writing a new parser for Kurt 2, inspired by nXIII's one, that doesn't require excessive parentheses. It's based on the design of the Pratt parser that nXIII linked.
Here's it parsing the script roijac posted:Note that the variable “foo” has been defined on the Stage beforehand. Kurt 2 has a built-in way of getting the options to a menu insert, by using Insert.options().some IPython output...
Something more complicated:In [2]: parsec("set foo to item 2 + 3 * 4 of positions + 10").stringify() Out[2]: u'set foo to ((item (2 + (3 * 4)) of positions) + 10)'
Looked at the code, why are you defining `fits` twice? (text.parser 87/110)
- blob8108
- Scratcher
1000+ posts
M30W - Code Scratch with Scratchblocks!
Thanks! Looks great!
Looked at the code, why are you defining `fits` twice? (text.parser 87/110)That's the old block plugin syntax parser from Kurt 1.4. That mistake is probably from when I was hacking it to still work on Kurt 2. I've pushed to Github now, you can see the code for the new parser on the kurt2 branch.
The new parser doesn't quite support all the block plugin syntax (notably the <> syntax for booleans; I couldn't find an easy way to hack it), but it's much nicer to use. Next up, custom blocks…
- Magnie
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
In general, all the ideas just make it harder to code and read. If you can switch between advanced mode and normal mode, it'll add more you have to code when translating it into another language. Indentation is probably expected to be automatic anyways (at least in a later version). And the only reason to use categories is internally. No point in using it in the actual coding especially with normal Scratch Blocks.Ok… I don't like that either, let's not put it in. We don't init vars inside code in ScratchThe terminology ‘event’ is not used in Scratch. What's bad about ‘when gf clicked’ like users would expect it?There is a new category called Event…Cryptic abbreviations like chg don't help users guess what it means.If you're an experienced programmer and are in advanced mode, then chances are, you'll know what it means.Having to indent every line is pretty redundantAUTOMATIC INDENTER!!!!!!!!!!!!!!! LIKE EVERY LEGITIMATE IDE!!!Stay close to the Scratch blocks - special casing say(message, secs=-1) sure doesn't make parsing easier.Well, this will be easier to translate other languages to, say, Java, Python, C, C++, Actionscript, JavaScript, C#, etc… I'm willing to write that code, if you want…I beg to differ:You don't have to use advanced mode…when gf clicked
say "Hello World!"
repeat 10
move 10 steps
turn cw 15 degrees // Comments
pen down
change X by 42
set [foo] to 128
change Y by foo
end
think "That's all folks!"
say "BTW: Eat At Joe's!" for 2 secs
StyledTextControl would be greatThanks, I'll have a look at those and maybe see what I can do. Hey, that's a really good idea, actually, and I don't plan on doing it either, so why not take it on yourself? Replace the wx.TextCtrl with something more appropriate for coding. Something like
Example of use for python here
▴ ▾ ▴ Macbook Pro 13" 2015 i5-5257U 8GB RAM - MacOS Sierra - Vivaldi v1.7 ▴ ▾ ▴
There are 10 types of people in this world, those who understand binary, those who don't, and those who know ternary.
- roijac
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
Back into coding again? Thanks, I'll have a look at those and maybe see what I can do.
- Magnie
- Scratcher
100+ posts
M30W - Code Scratch with Scratchblocks!
I've actually been programming an “MMO” for the last 2 or 3 months.Back into coding again? Thanks, I'll have a look at those and maybe see what I can do.
▴ ▾ ▴ Macbook Pro 13" 2015 i5-5257U 8GB RAM - MacOS Sierra - Vivaldi v1.7 ▴ ▾ ▴
There are 10 types of people in this world, those who understand binary, those who don't, and those who know ternary.
- davidkt
- Scratcher
1000+ posts
M30W - Code Scratch with Scratchblocks!
Okay, does anyone agree with this syntax:
event GFClick
say("Hello World!")
repeat 10
movesteps(10)
turncw(15) // Comments
pendown
__xpos__ += 42
foo = 128
__ypos__ += foo
end repeat
think("That's all folks!")
say('BTW: Eat At Joe\'s!')
end event
Remember when I looked like this? I still do.
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
- davidkt
- Scratcher
1000+ posts
M30W - Code Scratch with Scratchblocks!
Not that…Okay, does anyone agree with this syntax: […]No.
Remember when I looked like this? I still do.
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
- Discussion Forums
- » Advanced Topics
- » M30W - Code Scratch with Scratchblocks!