Discuss Scratch

savaka
Scratcher
1000+ posts

Is this possible

Is there any way the extension can access variables and lists from the project?
bobbybee
Scratcher
1000+ posts

Is this possible

Not without a mod.

“Ooo, can I call you Señorita Bee?” ~Chibi-Matoran
liam48D
Scratcher
1000+ posts

Is this possible

But with Snap! you can.

202e-202e-202e-202e-202e UNI-CODE~~~~~
savaka
Scratcher
1000+ posts

Is this possible

liam48D wrote:

But with Snap! you can.
But there aren't Snap! extensions.
liam48D
Scratcher
1000+ posts

Is this possible

savaka wrote:

liam48D wrote:

But with Snap! you can.
But there aren't Snap! extensions.
Yes there are, in the form of block libraries. They can be coded in either Snap!, JavaScript, or both simultaneously. I suggest you take a look into the JS Function block.

{my custom js block :: grey} :: control hat
run (JS function (code... :: grey) :: operators) :: control
// code...
alert("Hello, world!");

And just for a tidbit of extra info, here's the block and code for setting a variable:

{set variable name (name) local (local = false) value (value) :: variables} :: control hat
run (JS function [var_name] [local] [value] (code... :: grey) :: operators) with inputs (name) (local) (value) :: control
if (local === "true") {
  // Set a LOCAL variable. All local variables are stored in
  // this.variables.vars so by changing this.variables.vars[var_name]'s
  // value attribute we can change th evalue of the variable.
  this.variables.vars[var_name].value = value;
} else {
  // Set a GLOBAL variable. Same as above but changes one of the
  // variables stored in this.variables.parentFrame.vars.
  this.variables.parentFrame.vars[var_name].value = value;
}

After you've made your block just click on file => export blocks and select the blocks you want to export! This will save your block(s) to an XML file. If you want people to import it, click on file => Import.. and select your XML file you or somebody else downloaded from where you uploaded the XML file.

Have fun.

202e-202e-202e-202e-202e UNI-CODE~~~~~
savaka
Scratcher
1000+ posts

Is this possible

liam48D wrote:

savaka wrote:

liam48D wrote:

But with Snap! you can.
But there aren't Snap! extensions.
Yes there are, in the form of block libraries. They can be coded in either Snap!, JavaScript, or both simultaneously. I suggest you take a look into the JS Function block.

{my custom js block :: grey} :: control hat
run (JS function (code... :: grey) :: operators) :: control
// code...
alert("Hello, world!");

And just for a tidbit of extra info, here's the block and code for setting a variable:

{set variable name (name) local (local = false) value (value) :: variables} :: control hat
run (JS function [var_name] [local] [value] (code... :: grey) :: operators) with inputs (name) (local) (value) :: control
if (local === "true") {
  // Set a LOCAL variable. All local variables are stored in
  // this.variables.vars so by changing this.variables.vars[var_name]'s
  // value attribute we can change th evalue of the variable.
  this.variables.vars[var_name].value = value;
} else {
  // Set a GLOBAL variable. Same as above but changes one of the
  // variables stored in this.variables.parentFrame.vars.
  this.variables.parentFrame.vars[var_name].value = value;
}

After you've made your block just click on file => export blocks and select the blocks you want to export! This will save your block(s) to an XML file. If you want people to import it, click on file => Import.. and select your XML file you or somebody else downloaded from where you uploaded the XML file.

Have fun.
But it's not an extension, it's a collection of Snap! blocks which may or may not contain JavaScript.
liam48D
Scratcher
1000+ posts

Is this possible

savaka wrote:

But it's not an extension, it's a collection of Snap! blocks which may or may not contain JavaScript.

A Scratch extension - a collection of Scratch blocks which are coded in JavaScript.
A Snap! “extension” - a collection of Snap! blocks may or may not contain JavaScript.

Not to mention you can even make clones of the HTTP extensions in Snap! as well.

In terms of extensions (not the HTTP kind), the main difference is that with Scratch extensions you..

  • .. can use hat blocks
  • .. are limited to JavaScript
  • .. can't interact with anything outside of your block
  • .. are limited to strict hat, stack, reporter or boolean blocks

and in Snap! extensions you..

  • .. can't use hat blocks
  • .. can use JavaScript and normal blocks simultaneously
  • .. can interact with practically anything in the morphic world of Snap! - including other scripts or sprites
  • .. can create very customized block shapes and inputs (obviously excepting hat blocks)

But they generally work the same way.

202e-202e-202e-202e-202e UNI-CODE~~~~~
savaka
Scratcher
1000+ posts

Is this possible

liam48D wrote:

savaka wrote:

But it's not an extension, it's a collection of Snap! blocks which may or may not contain JavaScript.

A Scratch extension - a collection of Scratch blocks which are coded in JavaScript.
A Snap! “extension” - a collection of Snap! blocks may or may not contain JavaScript.

Not to mention you can even make clones of the HTTP extensions in Snap! as well.

In terms of extensions (not the HTTP kind), the main difference is that with Scratch extensions you..

  • .. can use hat blocks
  • .. are limited to JavaScript
  • .. can't interact with anything outside of your block
  • .. are limited to strict hat, stack, reporter or boolean blocks

and in Snap! extensions you..

  • .. can't use hat blocks
  • .. can use JavaScript and normal blocks simultaneously
  • .. can interact with practically anything in the morphic world of Snap! - including other scripts or sprites
  • .. can create very customized block shapes and inputs (obviously excepting hat blocks)

But they generally work the same way.
But what I'm trying to say is it's not an extension, it's a file containing Snap! blocks.
Znapi
Scratcher
500+ posts

Is this possible

savaka wrote:

But what I'm trying to say is it's not an extension, it's a file containing Snap! blocks.
A name is only a name. Both Scratch extensions and Snap! extensions are called “extensions”, but obviously they are different.
If you want a Scratch extension, then you won't be able to access the variables and lists. Maybe one day some 1337 hax0r might find a way.
savaka
Scratcher
1000+ posts

Is this possible

Znapi wrote:

savaka wrote:

But what I'm trying to say is it's not an extension, it's a file containing Snap! blocks.
A name is only a name. Both Scratch extensions and Snap! extensions are called “extensions”, but obviously they are different.
If you want a Scratch extension, then you won't be able to access the variables and lists. Maybe one day some 1337 hax0r might find a way.
Where have you seen anything official refer to any Snap! file as an “extension?”
Znapi
Scratcher
500+ posts

Is this possible

savaka wrote:

Where have you seen anything official refer to any Snap! file as an “extension?”
Yeah, your probably right. I'm not much of an expert on Snap!. I guess that is why liam put quotes around extension. I'd call them libraries.
The farthest I can get on accessing variables and lists in the projects is putting “%m.list” in a block label. I guess that wouldn't be too helpful for the block if you can't access a variable when you know its name though.
technoboy10
Scratcher
1000+ posts

Is this possible

savaka wrote:

Znapi wrote:

savaka wrote:

But what I'm trying to say is it's not an extension, it's a file containing Snap! blocks.
A name is only a name. Both Scratch extensions and Snap! extensions are called “extensions”, but obviously they are different.
If you want a Scratch extension, then you won't be able to access the variables and lists. Maybe one day some 1337 hax0r might find a way.
Where have you seen anything official refer to any Snap! file as an “extension?”
http://snap.berkeley.edu - scroll to "Use Devices with Snap[i!" and you'll see several extensions (which are mainly block files with a local backend).

trans rights are human rights
savaka
Scratcher
1000+ posts

Is this possible

technoboy10 wrote:

savaka wrote:

Znapi wrote:

savaka wrote:

But what I'm trying to say is it's not an extension, it's a file containing Snap! blocks.
A name is only a name. Both Scratch extensions and Snap! extensions are called “extensions”, but obviously they are different.
If you want a Scratch extension, then you won't be able to access the variables and lists. Maybe one day some 1337 hax0r might find a way.
Where have you seen anything official refer to any Snap! file as an “extension?”
http://snap.berkeley.edu - scroll to "Use Devices with Snap[i!" and you'll see several extensions (which are mainly block files with a local backend).
But they aren't called extensions. And why is this topic even open still? I'm closing it

Powered by DjangoBB