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!
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:
!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.
Last edited by rubiks_cube_guy238 (2011-01-23 19:45:46)
Offline
Cool. Bump.
Offline
Nice. I'm using this, and you're on the contributors list for my mod.
Offline
TheSuccessor wrote:
Nice. I'm using this, and you're on the contributors list for my mod.
Thanks for giving me credit.
Offline
And you're expecting me to beleive you that it actually works?
let's see...
*opens scratch source*
*clicks on the devmenu to open browser*
*goes to instructed path*
*makes changes*
*tests*
*dun dun dun...*
IT WORKS!!!
yayz!
i'm using it in Bingo! thanks!
you'll get credit of course!
Offline
LS97 wrote:
And you're expecting me to beleive you that it actually works?
let's see...
*opens scratch source*
*clicks on the devmenu to open browser*
*goes to instructed path*
*makes changes*
*tests*
*dun dun dun...*
IT WORKS!!!
yayz!
i'm using it in Bingo! thanks!
you'll get credit of course!
lol. thanks.
Offline
Bump
Offline
Billybob-Mario wrote:
Bump
Please don't. I already said that the block doesn't work completely.
Offline
rubiks_cube_guy238 wrote:
NOTE: THIS BLOCK DOES NOT ACTUALLY WORK. I ONLY FIGURED THIS OUT RECENTLY. SORRY.
What do you mean? It works perfectly!
Offline
Everytime I work on my old source code mod, someone gets mad at me. So I've pretty much given up squeak for python, but I still like to try out these forum blocks!
Offline
rubiks_cube_guy238 wrote:
Billybob-Mario wrote:
Bump
Please don't. I already said that the block doesn't work completely.
wht's wrong with it?
Offline
rubiks_cube_guy238 wrote:
NOTE: THIS BLOCK DOES NOT ACTUALLY WORK. I ONLY FIGURED THIS OUT RECENTLY. YOU WILL SEE WHY IF YOU PUT THE BLOCK IN A SPRITE AND SWITCH SO THAT YOU ARE VIEWING ANOTHER SPRITE.
Oh, I see why now. It also doesn't work in Presentation mode.
Offline
I made one that works! Add the code the the block specs but don't change the WhenHatBlockMorph class. Go to the ScriptableScratchMorph class and add this:
step
blocksBin
submorphsDo: [:each | (each isKindOf: WhenHatBlockMorph)
ifTrue: [each evaluateCondition ifTrue: [each start]]].
costume mediaStep ifTrue: [self costumeChanged]Last edited by MathWizz (2010-09-10 12:54:02)
Offline
So what's wrong with it?
Offline
TheSuccessor wrote:
So what's wrong with it?
Make this script:
<when <mouse down> >
<say [You clicked!] >
and then switch to another sprite. It won't work anymore.
Offline
Oh.
Offline
MathWizz wrote:
I made one that works! Add the code the the block specs but don't change the WhenHatBlockMorph class. Go to the ScriptableScratchMorph class and add this:
Code:
step blocksBin submorphsDo: [:each | (each isKindOf: WhenHatBlockMorph) ifTrue: [each evaluateCondition ifTrue: [each start]]]. costume mediaStep ifTrue: [self costumeChanged]
Wait... there is no blocksBin under scriptablescratchmorph
Offline
rubiks_cube_guy238 wrote:
(t6 isKindOf: WhenHatBlockMorph) ifTrue: [t6 color: Color red].
you actually don't need to remove that for some reason. IDK why but it wont turn red.
Offline
Pecola1 wrote:
MathWizz wrote:
I made one that works! Add the code the the block specs but don't change the WhenHatBlockMorph class. Go to the ScriptableScratchMorph class and add this:
Code:
step blocksBin submorphsDo: [:each | (each isKindOf: WhenHatBlockMorph) ifTrue: [each evaluateCondition ifTrue: [each start]]]. costume mediaStep ifTrue: [self costumeChanged]Wait... there is no blocksBin under scriptablescratchmorph
Just put in in 'other'. that seemed to work for me. you should add this to that tutorial, pecola.
Offline
hello12345678910 wrote:
Pecola1 wrote:
MathWizz wrote:
I made one that works! Add the code the the block specs but don't change the WhenHatBlockMorph class. Go to the ScriptableScratchMorph class and add this:
Code:
step blocksBin submorphsDo: [:each | (each isKindOf: WhenHatBlockMorph) ifTrue: [each evaluateCondition ifTrue: [each start]]]. costume mediaStep ifTrue: [self costumeChanged]Wait... there is no blocksBin under scriptablescratchmorph
Just put in in 'other'. that seemed to work for me. you should add this to that tutorial, pecola.
No I know that but blocks bin isn't even a variable under ScriptableScratchMorph class,
The class variables for ScriptableScratchMorph are:
classVariableNames: 'BlockColorDict BlockSpecDict DefaultBackgroundForm DefaultSpriteForm DoubleSize Experimental ListBlockColor MeowSound OldMeowPrefixReversed PopSound RandomGen Recorder ScratchOrigin TimerStartMSecs '
poolDictionaries: ''
category: 'Scratch-Objects'
however the instance ones include blocksBin:
Morph subclass: #ScriptableScratchMorph
instanceVariableNames: 'objName vars lists blocksBin isClone media costume costumeChangeMSecs filterPack visibility volume tempoBPM sceneStates '
Offline
MathWizz wrote:
I made one that works! Add the code the the block specs but don't change the WhenHatBlockMorph class. Go to the ScriptableScratchMorph class and add this:
Code:
step blocksBin submorphsDo: [:each | (each isKindOf: WhenHatBlockMorph) ifTrue: [each evaluateCondition ifTrue: [each start]]]. costume mediaStep ifTrue: [self costumeChanged]
Or, much more simply, in ScratchFrameMorph and ScratchPresenterMorph processWhenConditions, delete the line starting "true".
Offline
TheSuccessor wrote:
MathWizz wrote:
I made one that works! Add the code the the block specs but don't change the WhenHatBlockMorph class. Go to the ScriptableScratchMorph class and add this:
Code:
step blocksBin submorphsDo: [:each | (each isKindOf: WhenHatBlockMorph) ifTrue: [each evaluateCondition ifTrue: [each start]]]. costume mediaStep ifTrue: [self costumeChanged]Or, much more simply, in ScratchFrameMorph and ScratchPresenterMorph processWhenConditions, delete the line starting "true".
Does it work on another sprite?
Offline
TheSuccessor wrote:
MathWizz wrote:
I made one that works! Add the code the the block specs but don't change the WhenHatBlockMorph class. Go to the ScriptableScratchMorph class and add this:
Code:
step blocksBin submorphsDo: [:each | (each isKindOf: WhenHatBlockMorph) ifTrue: [each evaluateCondition ifTrue: [each start]]]. costume mediaStep ifTrue: [self costumeChanged]Or, much more simply, in ScratchFrameMorph and ScratchPresenterMorph processWhenConditions, delete the line starting "true".
Ohhhhhhhhh... I'll try that...
Offline
Pecola1 wrote:
Does it work on another sprite?
Yes!
Offline