zorket wrote:
Am I helpful for this topic? (Some have been stolen from others, but I gave credit)
Of course! As long as you tell me who it was made by, that's great, we get lots of additions!
Offline
sparks wrote:
zorket wrote:
Am I helpful for this topic? (Some have been stolen from others, but I gave credit)
Of course! As long as you tell me who it was made by, that's great, we get lots of additions!
u gonna add the <I recieve> block?
Offline
Thanks very much! I look forward to adding them and I'm glad you like the refurbishments!
If you could provide a picture of the block as it appears in the pallet as well as the coding, that would be awesome, otherwise I have to go and generate an image of the block for each one as I add it to the forum.
Offline
sparks wrote:
Thanks very much! I look forward to adding them and I'm glad you like the refurbishments!
If you could provide a picture of the block as it appears in the pallet as well as the coding, that would be awesome, otherwise I have to go and generate an image of the block for each one as I add it to the forum.
What do you mean pallet?
Offline
sparks wrote:
the pallet is the area in scratch/panther/byob that has all the blocks in it that you drag out.
ADD RUBIKS_CUBE_GUY'S BLOCK!!!!!!!!!!!!!!!!!!!!!!!!!!!
Offline
Whoa, that's a lot of blocks, SSBBM! I see I'm going to have my hands full updating the BYOB Block Library project, especially with the "key pressed" reporter.
Offline
sparks wrote:
woah! A HUGE contribution from SSBBM there, that's great! I have added them all up! Thanks very much!
slightly optimized (# of costumes) block:
(# of costumes)
script variables OC
set OC to (costume #)
switch to costume (0 + 0)
switch to costume (OC)
report (costume #)
Offline
nXIII wrote:
sparks wrote:
woah! A HUGE contribution from SSBBM there, that's great! I have added them all up! Thanks very much!
slightly optimized (# of costumes) block:
(# of costumes)
script variables OC
set OC to (costume #)
switch to costume (0 + 0)
switch to costume (OC)
report (costume #)
(# of costumes)
script variables OC Out
set OC to (costume #)
switch to costume 1
switch to costume ( (costume # ) - 1)
set Out to (costume #)
switch to costume (OC)
report (Out)
Offline
johnnydean1 wrote:
nXIII wrote:
sparks wrote:
woah! A HUGE contribution from SSBBM there, that's great! I have added them all up! Thanks very much!
slightly optimized (# of costumes) block:
(# of costumes)
script variables OC
set OC to (costume #)
switch to costume (0 + 0)
switch to costume (OC)
report (costume #)(# of costumes)
script variables OC Out
set OC to (costume #)
switch to costume 1
switch to costume ( (costume # ) - 1)
set Out to (costume #)
switch to costume (OC)
report (Out)
Oh... I fail.
Haha....
(# of costumes)
script variables OC Out
set OC to (costume #)
switch to costume (0+0)
set Out to (costume #)
switch to costume (OC)
report (Out)
Last edited by nXIII (2010-09-25 16:15:08)
Offline
nXIII wrote:
johnnydean1 wrote:
nXIII wrote:
slightly optimized (# of costumes) block:
(# of costumes)
script variables OC
set OC to (costume #)
switch to costume (0 + 0)
switch to costume (OC)
report (costume #)(# of costumes)
script variables OC Out
set OC to (costume #)
switch to costume 1
switch to costume ( (costume # ) - 1)
set Out to (costume #)
switch to costume (OC)
report (Out)Oh... I fail.
Haha....
(# of costumes)
script variables OC Out
set OC to (costume #)
switch to costume (0+0)
set Out to (costume #)
switch to costume (OC)
report (Out)
(# of costumes)
script variables check rebound
set check to 0
switch to costume (0+1)
repeat until <<costume number=0> and <rebound=1>
switch to costume ((costume #)+1)
change check by 1
if <(costume #>0)>
set rebound to 1
report(check)
lol
Last edited by bbbeb (2010-09-26 01:02:30)
Offline
bbbeb wrote:
(# of costumes)
script variables check rebound
set check to 0
switch to costume (0+1)
repeat until <<costume number=0> and <rebound=1>
switch to costume ((costume #)+1)
change check by 1
if <(costume #>0)[/blocks]>
set rebound to 1
report(check)
lol
Oh my gosh...
Optimization is making something run FASTER, not making it LONGER and SLOWER!
This:
(# of costumes)
script variables OC Out
set OC to (costume #)
switch to costume (0+0)
set Out to (costume #)
switch to costume (OC)
report (Out)
is the most optimized version. If you have one that's shorter which also works, please post it.
Last edited by nXIII (2010-09-26 10:31:13)
Offline
now get a block image for that
meowmeow55 wrote:
I see I'm going to have my hands full updating the BYOB Block Library project, especially with the "key pressed" reporter.
Yes, that's what I thought when I saw it too. That's one block where it's definitely useful to have it made for you in a project! And thanks for running that project, I'm sure lots of people find it useful. I might do the same thing for Panther but as CYOB blocks currently fail when you try to export them, there's not much point...
Offline
nXIII wrote:
bbbeb wrote:
(# of costumes)
script variables check rebound
set check to 0
switch to costume (0+1)
repeat until <<costume number=0> and <rebound=1>
switch to costume ((costume #)+1)
change check by 1
if <(costume #>0)[/blocks]>
set rebound to 1
report(check)
lolOh my gosh...
Optimization is making something run FASTER, not making it LONGER and SLOWER!
This:
(# of costumes)
script variables OC Out
set OC to (costume #)
switch to costume (0+0)
set Out to (costume #)
switch to costume (OC)
report (Out)
is the most optimized version. If you have one that's shorter which also works, please post it.
lol i thought that didnt work from the look
Offline
nXIII wrote:
bbbeb wrote:
Does costume zero equal last one?
it uses i mod size so yes, it will turn out to be the last costume.
Another way of prooving it is that
switch to costume 1
switch to costume ( (costume no.) - 1) "The same as 0"
Last edited by johnnydean1 (2010-09-27 02:58:57)
Offline
johnnydean1 wrote:
nXIII wrote:
bbbeb wrote:
Does costume zero equal last one?
it uses i mod size so yes, it will turn out to be the last costume.
Another way of prooving it is that
switch to costume 1
switch to costume ( (costume no.) - 1) "The same as 0"
Oh, yea.
Offline
Operators
(if <> then () else ()
blockspec:
('if %b then %s else %s' #r #if:then:else:)
if: t1 then: t2 else: t3 | t4 | t1 ifTrue: [t4 _ t2] ifFalse: [t4 _ t3]. ^ t4
Or you can use
if: t1 then: t2 else: t3 t1 ifTrue: [^ t2]. ^ t3
I'm not positive though
Last edited by zorket (2010-10-01 15:57:27)
Offline
got one for scratch source code.
Name of block: Search on...
Author: MidnightLeopard
Category: Sensing
blockspecs:
('%j %s' #- #doThis:on:)
sensing ops:
doThis: t1 on: t2 | engines l | 'google' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://www.google.com/#sclient=psy&hl=en&q=' , t2 , '&aq=f&aqi=g5&aql=&oq=&gs_rfai=&pbx=1&fp=ab5cdb1806fef4aa&safe=activet1']. 'yahoo' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://search.yahoo.com/search;_ylt=Aj.OqjGVrkBmY6mZqA_PSu.bvZx4?p=' , t2 , '&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-701']. 'scratch.mit.edu/' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://scratch.mit.edu/' , t2]. 'search scratch for' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://scratch.mit.edu/pages/results?cx=010101365770046705949:gg_q9cry0mq&cof=FORID:11&q=' , t2 , '&safe=active&sa=search']. 'IMDB' = t1 ifTrue: [ScratchPlugin primOpenURL: 'http://www.imdb.com/find?s=all&q=' , t2]. 'load' = t1 ifTrue: [^ 0]. ^ 0
scratch blocks -> command block morph -> private -> uncoloredArgMorphFor:
then delete all of that code and replace it with:
uncoloredArgMorphFor: t1 | t2 | t2 _ t1 at: 2. $a = t2 ifTrue: [^ AttributeArgMorph new choice: 'volume']. $b = t2 ifTrue: [^ BooleanArgMorph new]. $c = t2 ifTrue: [^ ColorArgMorph new showPalette: true]. $C = t2 ifTrue: [^ ColorArgMorph new showPalette: false]. $d = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '0'; menuSelector: #directionMenu]. $D = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '48'; menuSelector: #midiDrumMenu]. $R = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #operatorNames; choice: '+']. $e = t2 ifTrue: [^ EventTitleMorph new]. $f = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #mathFunctionNames; choice: 'sqrt']. $g = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #graphicEffectNames; choice: 'color']. $j = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #engineNames; choice: 'google']. $H = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #hookupSensorNames]. $h = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #hookupBooleanSensorNames]. $I = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1'; menuSelector: #midiInstrumentMenu]. $i = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1'; menuSelector: #listIndexMenu]. $k = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #keyNames; choice: 'space']. $L = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #listVarMenu]. $l = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #costumeNames; choice: 'costume1']. $m = t2 ifTrue: [^ SpriteArgMorph new]. $M = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #motorNames]. $n = t2 ifTrue: [^ ExpressionArgMorph new numExpression: '10']. $N = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '60'; menuSelector: #noteSelector]. $s = t2 ifTrue: [^ ExpressionArgMorph new stringExpression: '']. $S = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #soundNames; choice: 'pop']. $v = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #varNamesMenu; choice: '']. $W = t2 ifTrue: [^ ChoiceArgMorph new getOptionsSelector: #motorDirection]. $x = t2 ifTrue: [^ ChoiceOrExpressionArgMorph new getOptionsSelector: #sceneNames; choice: '']. $y = t2 ifTrue: [^ ExpressionArgMorphWithMenu new numExpression: '1'; menuSelector: #listIndexForDeleteMenu]. ^ ExpressionArgMorph new numExpression: '10'
then scratch objects -> scriptable scratch morph -> sensing ops ->
engineNames ^ #('google' 'yahoo' 'scratch.mit.edu/' 'search scratch for' 'IMDB' 'load' )
it looks like this
it can search google, IMDB, yahoo, scratch, or go to a scratch url. Also, the load option does nothing, but can be used to test if your user has added this block, like:
^when flag clicked^
[set 'has block' to '0']
[load '']
[set 'has block' to '1']
this is the best piece of code I have ever made in smalltalk, so please tell me how it goes!
Offline