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

#1 2011-06-10 23:07:35

Scriptmaster01
Scratcher
Registered: 2011-03-15
Posts: 6

Buttons

I am currently in the process of making a mod called Condor. I have added three new categories: Other, List, and BlockLibrary. My only problem is with List. I want to move the 'Make a list' and 'Delete a list' buttons moved from the variables category. I've looked over and over in the source code but I can't find how I should do this in there. If someone can tell me how or at the very least point me in the right direction I would greatly appreciate it.
[blocks]
<when I receive[ my awnswer
<forever>
<say[ thankyou
<end>
[/blocks]

Offline

 

#2 2011-06-11 01:22:13

undefeatedgames
Scratcher
Registered: 2011-05-22
Posts: 1000+

Re: Buttons

Scriptmaster01 wrote:

I am currently in the process of making a mod called Condor. I have added three new categories: Other, List, and BlockLibrary. My only problem is with List. I want to move the 'Make a list' and 'Delete a list' buttons moved from the variables category. I've looked over and over in the source code but I can't find how I should do this in there. If someone can tell me how or at the very least point me in the right direction I would greatly appreciate it.
[blocks]
<when I receive[ my awnswer
<forever>
<say[ thankyou
<end>
[/blocks]

I'm reporting this so it can be moved to Advanced Topics. You'll probably get more help there!


Please call me udg or bearsfan, not undefeated.
Scratch and Misc.! Click here for Misc.'s Successorhttps://lh3.googleusercontent.com/-jkhes3yzmQk/T7G_BnxT9xI/AAAAAAAABYI/xhoN1Jk2M08/s513/sigp1.gif

Offline

 

#3 2011-06-11 07:14:50

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: Buttons

undefeatedgames wrote:

Scriptmaster01 wrote:

I am currently in the process of making a mod called Condor. I have added three new categories: Other, List, and BlockLibrary. My only problem is with List. I want to move the 'Make a list' and 'Delete a list' buttons moved from the variables category. I've looked over and over in the source code but I can't find how I should do this in there. If someone can tell me how or at the very least point me in the right direction I would greatly appreciate it.
[blocks]
<when I receive[ my awnswer
<forever>
<say[ thankyou
<end>
[/blocks]

I'm reporting this so it can be moved to Advanced Topics. You'll probably get more help there!

I can see you becoming a mod sometime in the future. @Scriptmaster01: I think that it's under Scratch-Objects -> ScriptableScratchMorph -> blocks -> addGenericListBlocksTo:y:
I hope that helps!


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

#4 2011-06-11 22:59:04

Scriptmaster01
Scratcher
Registered: 2011-03-15
Posts: 6

Re: Buttons

yea that definitely helped. In case anyone out there needs to know how to do it this is what you do:
go to Scratch-Objects --> ScriptableScratchMorph -> instance -> variables -> variablesPage you should come up with something like this

Code:

variablesPage
    | t1 t2 t3 t4 t5 t6 t7 t8 |
    t1 _ ScratchBlockPaletteMorph new color: (Color
                    r: 0.8
                    g: 0.8
                    b: 1.0);
             borderWidth: 0.
    t2 _ ScratchFrameMorph buttonLabel: 'Make a variable' localized selector: #addGlobalVariable.
    (self isKindOf: ScratchSpriteMorph)
        ifTrue: [t2 actionSelector: #addVariable].
    t3 _ ScratchFrameMorph buttonLabel: 'Delete a variable' localized selector: #deleteVariable.
    t6 _ 13.
    t1 addMorph: (t2 target: self;
         position: t6 @ 7).
    t7 _ t2 bottom + 3.
    t4 _ self varNames size > 0.
    (t5 _ self ownerThatIsA: ScratchStageMorph)
        ifNotNil: [t5 varNames size > 0 ifTrue: [t4 _ true]].
    t4
        ifTrue: 
            [t1 addMorph: (t3 target: self;
                 position: t6 @ t7).
            t7 _ t3 bottom + 10.
            t7 _ self
                        addVariableReportersTo: t1
                        x: t6
                        y: t7.
            t7 _ t7 + 12.
            t7 _ self
                        addGenericVariableBlocksTo: t1
                        x: t6
                        y: t7].
    self addGenericListBlocksTo: t1 y: t7.
    t1 updateWatcherButtonsForFrame: (self ownerThatIsA: ScratchFrameMorph).
    t8 _ t1 submorphs inject: 0 into: [:t9 :t10 | t9 max: t10 right].
    t1 extent: t8 + 10 @ t7.
    ^ t1

Delete the line: self addGenericListBlocksTo: t1 y: t7.
click accept.
Now you go to Scratch-Objects --> ScriptableScratchMorph ->instance -> blocks -> viewerPageForCategory you should up with

Code:

viewerPageForCategory: t1 
    | t2 t3 t4 |
    t1 = 'variables' ifTrue: [^ self variablesPage].
    t1 = 'motion' ifTrue: [^ self viewerPageForMotion].
    t1 = 'sensing' ifTrue: [^ self viewerPageForSensing].
    t2 _ ScratchBlockPaletteMorph new.
    t3 _ 12.
    t4 _ 10.
    (self blocksFor: t1)
        do: [:t5 | t5 = #- | (t5 = #~)
                ifTrue: 
                    [t5 = #- ifTrue: [t4 _ t4 + 15].
                    t5 = #~ ifTrue: [t4 _ t4 + 5]]
                ifFalse: [t4 _ self
                                createBlock: t5
                                atPosition: t3 @ t4
                                onPage: t2]].
    ^ t2

add
t1 = 'list' ifTrue: [^ self listPage].
to the string
click accept.
Now you add a method with this code

Code:

listPage
    | t1 t2 t3 |
    t2 _ self.
    t1 _ ScratchBlockPaletteMorph new color: (Color
                    r: 0.8
                    g: 0.8
                    b: 1.0);
             borderWidth: 0.
    self addGenericListBlocksTo: t1 y: t2.
    t1 updateWatcherButtonsForFrame: (self ownerThatIsA: ScratchFrameMorph).
    t3 _ t1 submorphs inject: 0 into: [:t4 :t5 | t4 max: t5 right].
    ^ t1

click accept
Lastly go to addGenericListBlocksTo:y: and replace it with this code

Code:

addGenericListBlocksTo: t1 y: t2 
    | t3 t4 t5 t6 t7 t8 |
    t3 _ ScratchFrameMorph buttonLabel: 'Make a list' localized selector: #addList.
    (self isKindOf: ScratchStageMorph)
        ifTrue: [t3 actionSelector: #addGlobalList].
    t4 _ ScratchFrameMorph buttonLabel: 'Delete a list' localized selector: #deleteList.
    t5 _ 13.
    t1 addMorph: (t3 target: self;
         position: t5 @ 7).
    t6 _ t3 bottom + 3.
    t7 _ self listVarNames size > 0.
    (t8 _ self ownerThatIsA: ScratchStageMorph)
        ifNotNil: [t8 listVarNames size > 0 ifTrue: [t7 _ true]].
    t7 ifFalse: [^ self].
    t1 addMorph: (t4 target: self;
         position: t5 @ t6).
    t6 _ t4 bottom + 10.
    t6 _ (self
                addListReportersTo: t1
                x: t5
                y: t6)
                + 10.
    (self blocksFor: 'list')
        do: [:t9 | t9 = #- | (t9 = #~)
                ifTrue: 
                    [t9 = #- ifTrue: [t6 _ t6 + 15].
                    t9 = #~ ifTrue: [t6 _ t6 + 5]]
                ifFalse: 
                    [t6 _ self
                                createBlock: t9
                                atPosition: t5 @ t6
                                onPage: t1.
                    t1 submorphs last color: ScriptableScratchMorph listBlockColor]]

I would like to thank Scratcher7_13 for helping point me in the right direction

Offline

 

Board footer