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

#26 2011-01-28 12:13:34

paperninjamaster
Scratcher
Registered: 2010-08-23
Posts: 40

Re: How to make a working [when <> is true] block

It looks like the [wait untill <  >] block


This is a message to new Scratchers
Just keep on Scratching  smile

Offline

 

#27 2011-02-01 14:46:03

Pecola1
Scratcher
Registered: 2010-09-06
Posts: 1000+

Re: How to make a working [when <> is true] block

TheSuccessor wrote:

Pecola1 wrote:

Does it work on another sprite?

Yes!

LOL I seriously did that on RKT compares IMG but didn't try testing it, then forgot to save it AND forgot where it was.


If you are reading this, please read to the end, because if you don't you won't know what's at the end. Don't just skip to the end though otherwise you won't be able to read the middle, which is most important. Now you must be wondering why you just read all that, the reason is you may have not noticed something, read it again and see if you notice it this time  smile

Offline

 

#28 2011-12-24 07:11:14

FloppyDash
Scratcher
Registered: 2011-10-09
Posts: 4

Re: How to make a working [when <> is true] block

How do you get to the ScriptableScratchMorph?
smile  smile  smile  smile  smile


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Offline

 

#29 2011-12-25 16:01:11

CylonToast
Scratcher
Registered: 2011-10-06
Posts: 1000+

Re: How to make a working [when <> is true] block

rubiks_cube_guy238 wrote:

Okay. Go to Scratch-Blocks->WhenHatBlockMorph and add two new methods in the instance side:

stepTime
^ 0.1

and

step
self evaluateCondition ifTrue: [self start]

Now add a new block in the ScriptableScratchMorph blockSpecs:

('' #W #-)

(We don't give the block a name because the WhenHatBlockMorph class automatically adds the label.)

Finally, go to ScriptableScratchMorph->blockFromTuple:receiver: and delete the text that says

(t6 isKindOf: WhenHatBlockMorph) ifTrue: [t6 color: Color red].

It's that easy!  tongue

BUG FIX: The block won't work if you switch to another sprite or switch to presentation mode. To fix this, go back to WhenHatBlockMorph and delete the #step and #stepTime methods. Now, go to ScriptableScratchMorph step:

step
    blocksBin
        submorphsDo: [:each | (each isKindOf: WhenHatBlockMorph)
                ifTrue: [each evaluateCondition ifTrue: [each start]]].
    costume mediaStep ifTrue: [self costumeChanged]

Credit to MathWizz for the bug fix.

FURTHER BUG FIX: This isn't exactly a bug fix, but it's simpler. Copy the following code:

Code:

!ScratchFrameMorph methodsFor: 'stepping'!
processWhenConditions
    | t1 |
    "true ifTrue: [^ self]."
    t1 _ workPane submorphs select: [:t2 | t2 isKindOf: ScriptableScratchMorph].
    t1 _ t1 copyWith: workPane.
    t1 do: [:t3 | t3 scripts do: [:t4 | (t4 isMemberOf: WhenHatBlockMorph)
                ifTrue: [(t4 hasRunningProcess not and: [t4 evaluateCondition])
                        ifTrue: [t4 start; layoutChanged]]]]! !

!ScratchPresenterMorph methodsFor: 'event handling'!
processWhenConditions
    | t1 |
    "true ifTrue: [^ self]."
    t1 _ stage submorphs select: [:t2 | t2 isKindOf: ScriptableScratchMorph].
    t1 _ t1 copyWith: stage.
    t1 do: [:t3 | t3 scripts do: [:t4 | (t4 isMemberOf: WhenHatBlockMorph)
                ifTrue: [(t4 hasRunningProcess not and: [t4 evaluateCondition])
                        ifTrue: [t4 start; layoutChanged]]]]! !

paste it in a workspace (you find the option on the open browser menu), highlight it, right-click, 'more...', 'file it in'.

Credit to TheSuccessor.

Can you make it in a Scratch Mod?


https://lh3.googleusercontent.com/-Axvm8TlDHc4/Tocl0m1Z39I/AAAAAAAACAI/j32nzVU69DU/animated-peanut.gifhttp://gifsoup.com/webroot/animatedgifs/136991_o.gif

Offline

 

#30 2011-12-28 18:45:47

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: How to make a working [when <> is true] block

Wow! Very helpful!


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

#31 2011-12-28 18:49:20

jslomba
Scratcher
Registered: 2009-09-25
Posts: 1000+

Re: How to make a working [when <> is true] block

Lol, I figured out how to make this first. Whatever, though.


the the the the the

Offline

 

Board footer