Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Is it possible to call a custom block on a cloned Sprite in BYOB 3.1?
- RDoc
- Scratcher
46 posts
Is it possible to call a custom block on a cloned Sprite in BYOB 3.1?
What I'm trying to do use a bunch of clones of a Sprite with custom blocks defined in it, but I need to be able to run or call those custom blocks with arguments. This works fine on the prototype (parent) Sprite, but if I set a variable to the Sprite, or a clone of the Sprite, there seems to be no way to access the custom blocks in it.
Eventually I'd like to make child Sprites with more custom blocks using hidden parent Sprites as prototypes.
Eventually I'd like to make child Sprites with more custom blocks using hidden parent Sprites as prototypes.
Last edited by RDoc (Oct. 9, 2013 16:26:09)
- scimonster
- Scratcher
1000+ posts
Is it possible to call a custom block on a cloned Sprite in BYOB 3.1?
I think it's possible if you set a variable to the block, but not otherwise. In any case, no-one uses BYOB 3.1 anymore. Now it's all Snap!.
Retired Community Moderator
BTW, i run Google Chrome 41.0.2272.101 on a Linux system - Ubuntu 14.04. NEW: iPad 4th gen. w/retina.
418 I'm a teapot (original - to be read by bored computer geeks)
THE GAME (you just lost)
; THE SEMICOLON LIVES ON IN OUR SIGS
- DigiTechs
- Scratcher
500+ posts
Is it possible to call a custom block on a cloned Sprite in BYOB 3.1?
Snap!.I use BYOB 3.1 sometimes though :c I think it's possible if you set a variable to the block, but not otherwise. In any case, no-one uses BYOB 3.1 anymore. Now it's all
I do, in fact, have my own site; it's here.
I'm also working on a thing called Fetch. Look at it here!
@thisandagain pls explain. @thisandagain pls explain. @thisandagain pls explain. @thisandagain pls explain. @thisandagain pls explain.
- RDoc
- Scratcher
46 posts
Is it possible to call a custom block on a cloned Sprite in BYOB 3.1?
I'd like to use Snap!, but I'm teaching kids programming and Snap! looks a bit raw ATM for them. BYOB isn't quite as nice as Snap!, but seems a lot more solid and has an off-line editor. Once Snap! settles down, I'll use it.
I worked out the answer to my original question.
CREATE is a constructor custom block that returns a clone of the sprite SPRITE. SETV is a custom block with an input defined in SPRITE that I want to call. VAR is a variable I want to set to a clone of SPRITE.
set VAR to (call(CREATE of SPRITE)) // sets VAR to a new clone of SPRITE (Sprite1)
run((SETV of SPRITE) of VAR) with inputs 3 // run the SETV custom block defined in SPRITE on Sprite1 (in VAR)
This all winds up with VAR pointing to Sprite1, and its values being set by the SETV function with input 3. The parent sprite SPRITE isn't changed apart from having a new child.
It also works to set a variable to a function:
set FVAR to (CREATE of SPRITE) // set FVAR to the custom block CREATE defined in SPRITE
set VAR to (call(FVAR)) // load VAR with a clone of SPRITE, created by calling the function pointed to by FVAR
I worked out the answer to my original question.
CREATE is a constructor custom block that returns a clone of the sprite SPRITE. SETV is a custom block with an input defined in SPRITE that I want to call. VAR is a variable I want to set to a clone of SPRITE.
set VAR to (call(CREATE of SPRITE)) // sets VAR to a new clone of SPRITE (Sprite1)
run((SETV of SPRITE) of VAR) with inputs 3 // run the SETV custom block defined in SPRITE on Sprite1 (in VAR)
This all winds up with VAR pointing to Sprite1, and its values being set by the SETV function with input 3. The parent sprite SPRITE isn't changed apart from having a new child.
It also works to set a variable to a function:
set FVAR to (CREATE of SPRITE) // set FVAR to the custom block CREATE defined in SPRITE
set VAR to (call(FVAR)) // load VAR with a clone of SPRITE, created by calling the function pointed to by FVAR
Last edited by RDoc (Oct. 9, 2013 22:24:01)
- Discussion Forums
- » Advanced Topics
- » Is it possible to call a custom block on a cloned Sprite in BYOB 3.1?