This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-12-27 10:03:55

rubiks_cube_guy238
Scratcher
Registered: 2009-07-02
Posts: 100+

How to make a working [tell [Sprite] to []] block

commandSpec:

Code:

('tell %m to' #c #doTellSpriteTo)

code: (put in ScratchProcess instance private-special forms)

Code:

doTellSpriteTo
    | t1 t2 t3 |
    t1 _ stackFrame expression.
    t2 _ stackFrame arguments.
    t2 size = 0
        ifTrue: 
            [t3 _ t1 argumentAt: 1.
            ^ self pushStackFrame: (ScratchStackFrame new expression: t3)].
    self popStackFrame.
    t3 _ t1 fullCopy.
    t3
        allMorphsDo: [:t4 | (t4 respondsTo: #receiver:)
                ifTrue: [t4 receiver: (ScriptableScratchMorph new coerceSpriteArg: t2 first)]].
    self pushStackFrame: (ScratchStackFrame new expression: t3 firstBlockList)

finally, go to SpriteArgMorph other presentMenu, and after where it says

Code:

t3 do: [:t8 | t4 add: t8 objName action: t8].

put

Code:

t2 = #doTellSpriteTo
        ifTrue: 
            [t4 labels at: 1 put: 'Stage' localized asUTF8.
            t4 selections at: 1 put: t1 workPane].

__________________________________________________________________________
For those of you out there who want to find a 'simpler' way of doing it,

Code:

tellSprite: t1 to: t2
t1 do: t2

will NOT work!!!!

Last edited by rubiks_cube_guy238 (2010-12-27 10:29:24)


The glass is never half full nor half empty; it is twice as large as it needs to be.

Offline

 

#2 2010-12-27 10:23:32

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: How to make a working [tell [Sprite] to []] block

What things are listed under the second argument, and why does your blockspec only have one argument in it?  smile

Last edited by sparks (2010-12-27 10:24:17)


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

Board footer