Discuss Scratch

-Io-
Scratcher
1000+ posts

Snap! user discussion

After seeing this issue/request I started playing around with Snap! (literally) to see if I could make it with pure JavaScript getters and setters. I knew variables had to be stored in objects, so I started looking around the code and found .silentFind and .find which did the job of finding the objects nicely. The only thing I had to handle is so it found variables outside of the custom block. This was pretty easy with a custom reporter because they always have a parent context, and if they don't they are detached from everything so I just had to care for global vars and go 2 parent frames up; but I cannot find how to do this with (custom) stack blocks since they only have a parent context when they aren't the final block in a script. Is there a way of around this?

Here's a demo I made:
http://snap.berkeley.edu/snapsource/snap.html#present:Username=jrbc2&ProjectName=Parent%20context%20test

Note that I did achieve making getters and setters, the only issue is this.

bharvey
Scratcher
1000+ posts

Snap! user discussion

-Io- wrote:

The only thing I had to handle is so it found variables outside of the custom block.
Well, the last command of a script can use and set variables, so just trace out what happens when you do that!

dawidkrainski
Scratcher
100+ posts

Snap! user discussion

I made it using JS to change the code and use this with standard
(variable)
and
set [ v] to []

Last edited by dawidkrainski (Dec. 2, 2016 21:24:09)

-Io-
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

-Io- wrote:

The only thing I had to handle is so it found variables outside of the custom block.
Well, the last command of a script can use and set variables, so just trace out what happens when you do that!
But said last command is a custom block, and I want it to find script vars outside its context. As I said, its parent context (which should be the script the custom block was ran from) isn't accessible (it is null) if it is the last command in it, and I need to be able to access it in order to access the script vars it has

EDIT: Okay, I think I have found the solution! homeContext, although its .expression is null, seems to work!
EDIT2: Thanks, although I ended up figuring it out myself

dawidkrainski wrote:

I made it using JS to change the code and use this with standard
(variable)
and
set [ v] to []
Yes, mine too. I'm just not changing the code directly. My JS is just giving a getter and setter to the .value property of the variable with Object.defineProperty.

Last edited by -Io- (Dec. 2, 2016 22:14:15)


dawidkrainski
Scratcher
100+ posts

Snap! user discussion

I posted this before…….. but in wrong place:

It fails becaouse of tail call:
SCRIPT:
a()
b()
c()

STACK:
[stack]
a
[current] a
b
c

[stack]
b
c

[stack]
b
[current] b
c

[stack]
c

c

[RETURN VALUE] result of c
-Io-
Scratcher
1000+ posts

Snap! user discussion

Okay, finished! Here's a getter and setter for variables:
http://snap.berkeley.edu/snapsource/snap.html#present:Username=jrbc2&ProjectName=getter%20setter
Non-intrusive, setup-less, live, and uses pure JS ^.^

bharvey
Scratcher
1000+ posts

Snap! user discussion

-Io- wrote:

Okay, finished!
That's very nice. This isn't your fault, but I find the interaction of active variables and watchers unaesthetic; I don't want a variable's value to keep changing when my program hasn't done anything with it, but watchers keep calling the getter. This wouldn't matter, I guess, if your examples didn't involve randomness. Well, except for the temporary variable, which should really disappear when the script finishes, but I guess that's not really because of its activeness.

The most typical use of active variables is for debugging; the variable works just like a variable, but logs its interactions. Or the setter checks for an invalid input and does a PAUSE ALL when it sees one.

Oh, it's also unaesthetic, in your example, that you have to use global variables for GREETING etc. It would be nice if those were local properties of variable C somehow. You could do that by putting the GIVE VAR C block inside a lambda with parameters GREETING etc, and putting that inside a RUN, right?

P.S. How come the people's names in Spanish translate most but not all of the English names?

-Io-
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

That's very nice. This isn't your fault, but I find the interaction of active variables and watchers unaesthetic; I don't want a variable's value to keep changing when my program hasn't done anything with it, but watchers keep calling the getter. This wouldn't matter, I guess, if your examples didn't involve randomness. Well, except for the temporary variable, which should really disappear when the script finishes, but I guess that's not really because of its activeness.
Technically it doesn't change, it just behaves the same as if I was doing getter(), instead of just var. I find it a bit unaesthetic too but it's at least fun to watch, and it's a bit better than if the watcher had a static value and the reporter were returning something completely different.

bharvey wrote:

Oh, it's also unaesthetic, in your example, that you have to use global variables for GREETING etc. It would be nice if those were local properties of variable C somehow. You could do that by putting the GIVE VAR C block inside a lambda with parameters GREETING etc, and putting that inside a RUN, right?
Oh, sure, I was just a bit lazy. Updated.

bharvey wrote:

P.S. How come the people's names in Spanish translate most but not all of the English names?
They either never got one (probably because they're of relatively recent origins) or I don't know their translations, and sometimes they're a bit bizarre, like Henry and Enrique or Elizabeth and Isabel.

Looking around a bit, apparently, Jessica translates to Yéssica, which imo is a bit ugly.
William translates to Guillermo.
Ruby is an English word, so, kind of obvious why it wouldn't have a translation
Amelia doesn't change in translation.
Also, “Hi” and “Hey” don't have actual translations. “Holi” (which is not an actual word) is used like “Hi”, and “Hey” doesn't change.

Changed a few so there isn't much discrepancy between the translations.

Fun fact: bizarre and bizarro have completely different meanings.

bharvey
Scratcher
1000+ posts

Snap! user discussion

-Io- wrote:

Ruby is an English word, so, kind of obvious why it wouldn't have a translation
Google says “rubí.” There has to be some Spanish word for that red gemstone, right?
Amelia doesn't change in translation.
Interesting. Google agrees with you, but if you change it to Spanish->English it corrects your Spanish spelling to “Amelía.” I kinda knew there was an accent but I was guessing it went over the “e.”

Fun fact: bizarre and bizarro have completely different meanings.
Eh?

dictionary.com wrote:

bizarro
adjective
Bizarre: along comes a bizarro piece of work like Trudy/ But subsequent experts on Bizarro World cinema rejected that view
[1970s+; fr a character Bizarro in the “Superman” comic strips]

-Io-
Scratcher
1000+ posts

Snap! user discussion

bharvey wrote:

-Io- wrote:

Ruby is an English word, so, kind of obvious why it wouldn't have a translation
Google says “rubí.” There has to be some Spanish word for that red gemstone, right?
Yes, it is “rubí”, but unfortunately it isn't a name like in English

Amelia doesn't change in translation.
Interesting. Google agrees with you, but if you change it to Spanish->English it corrects your Spanish spelling to “Amelía.” I kinda knew there was an accent but I was guessing it went over the “e.”
Oh, really? I've never heard either so didn't know.

Fun fact: bizarre and bizarro have completely different meanings.
Eh?

dictionary.com wrote:

bizarro
adjective
Bizarre: along comes a bizarro piece of work like Trudy/ But subsequent experts on Bizarro World cinema rejected that view
[1970s+; fr a character Bizarro in the “Superman” comic strips]
Oops, sorry, I meant Spanish's bizarro
Bizarro means brave, courageous, valiant.

bharvey
Scratcher
1000+ posts

Snap! user discussion

-Io- wrote:

Bizarro means brave, courageous, valiant.
Interesting. Is that a recent slang formation from “bizarrely brave” etc., or does it actually have a separate etymology?

dawidkrainski
Scratcher
100+ posts

Snap! user discussion

OS in Snap! !!!
YAY! First public prelease of my OS in Snap! ! I have started this yesterday. Today basic functions are avalible.
Click here to open Snap! project!
bharvey
Scratcher
1000+ posts

Snap! user discussion

dawidkrainski wrote:

First public prelease of my OS in Snap! !
Okay, I need some help understanding this. It looks like you're reinventing Morphic, but I can't figure out how to interact with it. Is the idea that I write additional Snap! code to create morphs, or is there a way to interact from within the project that I'm missing?

dawidkrainski
Scratcher
100+ posts

Snap! user discussion

Now, It's only prototype. You can click FPS ON/OFF to toggle “FPS” bar on the left.
dawidkrainski
Scratcher
100+ posts

Snap! user discussion

And, when I was working on first working version, I found a bug. I reported them to github.
dawidkrainski
Scratcher
100+ posts

Snap! user discussion

Update: Now there is a shutdown button.
Gamificat
Scratcher
3 posts

Snap! user discussion

Hi and excuses! I don't know how to start a new topic…

As a user, I want to thank you for building Snap! I prefer to learn and teach programming without using propietary software

I have some questions:

1) The reference manual of Snap! it's not for begginers… That's why I started to create some small/easy courses (in catalan): http://www.gamifi.cat/detot/decodi/snap/ The question is: have you got another manual for begginers?

2) I'm talking with Willa from ScratchEd to start a Scratch Meetup in Barcelona: there will be a Snap! meetups as well in the near future?

3) Some months ago I have asked Jens for a couple of blocks (set volume to % and change volume by %). But I don't want to disturb him… Do you know about it? Will the blocks come to Snap!?

Thanks again for your work. I'm learning a lot
Best regards,
rita
bloopperson
New to Scratch
5 posts

Snap! user discussion

One last question for my hangman project, how do I display my guessed letters. Let's say there are blank spaces according to the length of the word, and the player gets a correct guess, how would I display that correct guess?
dawidkrainski
Scratcher
100+ posts

Snap! user discussion

say (join [Guessed text: ] (guessed) @delInput@addInput ::operators) for (X) secs
???
dawidkrainski
Scratcher
100+ posts

Snap! user discussion

Or do you mean
(join arguments: list (list) ::operators) // Drag (list) block to arrows
?

Last edited by dawidkrainski (Dec. 13, 2016 15:24:30)

Powered by DjangoBB