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

#1 2010-08-09 04:49:25

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Convert a Script into a block!

I have a script and would like it changed into a block, anyone who can do it here it is:
http://a.imageshack.us/img33/6476/scriptss.gif

Last edited by johnnydean1 (2010-08-09 05:37:35)


You can now reach me on Twitter @johnnydean1_

Offline

 

#2 2010-08-09 04:58:04

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Convert a Script into a block!

what's this for? i'd be happy to help (it's not hard at all anyway) but the code seems a bit long, i might be able to shorten it if you can tell me what it's for

Offline

 

#3 2010-08-09 05:08:01

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

Well Ive just improved, its for mesh list sharing.


You can now reach me on Twitter @johnnydean1_

Offline

 

#4 2010-08-09 05:14:52

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

Sorry a new version!


You can now reach me on Twitter @johnnydean1_

Offline

 

#5 2010-08-09 05:16:08

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

List1 and List2 are examples of lists


You can now reach me on Twitter @johnnydean1_

Offline

 

#6 2010-08-09 05:33:10

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

Another update, using Panther blocks.


You can now reach me on Twitter @johnnydean1_

Offline

 

#7 2010-08-09 05:34:24

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

Code for the
get $String$ from mesh

reporter

    | t11 t12 t13 t14 input output|
input_ t1.
    t11 _ #('slider' 'light' 'sound' 'resistance' ).
    t11 _ t11 , #('-' 'tilt' 'distance' ).
t14_ t11.
    (t12 _ self ownerThatIsA: ScratchStageMorph) ifNotNil: [t12 scratchServer
            ifNotNil:
                [t13 _ t12 scratchServer sensorNames.
                t13 size > 0 ifTrue: [
t14_ self concatenate: (t11) with: ('-').
t11_t12 scratchServer sensorNames.
t14_ self concatenate: (t14) with: (t11).
]]].
t11_ #('').
t11_ self letter: (2) of: (t11).
t12_ self concatenate: (t11) with: (input).
t12_ self concatenate: (t12) with: (t11).
t14_ t14 asString.
t13_ self indexOf: (t12) startingAt: (0) in: (t14).
t13 = 0
ifTrue: [
output_ 0.
]
ifFalse: [
output_ self sensor: (input).
].
^ output.

This reports 0 not error! so, thats why!

Last edited by johnnydean1 (2010-08-09 05:52:50)


You can now reach me on Twitter @johnnydean1_

Offline

 

#8 2010-08-09 08:19:17

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Convert a Script into a block!

me still no understand  tongue
so did you solve your problem?

Offline

 

#9 2010-08-09 09:19:21

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

What problem, can you just turn the script into a block.


You can now reach me on Twitter @johnnydean1_

Offline

 

#10 2010-08-09 09:21:46

Gveradux
Scratcher
Registered: 2010-06-18
Posts: 100+

Re: Convert a Script into a block!

basically, yes. i don't know how. But the information of you script can be transferred into the Browser to create a block. Sadly, uploading this will destroy the block, and it will nott work. SO I suggest not making a block.

Offline

 

#11 2010-08-09 09:25:44

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

Ahh your not getting me, I want to make this script into a block to use in a change set. I do know squeak and could make it myself if I wanted to.


You can now reach me on Twitter @johnnydean1_

Offline

 

#12 2010-08-09 10:30:02

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

I attempted but its not working. I missed out the last bit:

|  t2 t3 t4 t5 t6 t7 t8 t9 t10 repeat  t11 t12 t13 t14 input output quote trues temp deafult |

deafult_ 'No list'.
quote_ #('').
quote_ self letter: (3) of: (quote).

repeat_ 50.
t10_ deafult.
t6_ 0.
t5_ 0.
t4_ ''.
t7_ 0.

repeat timesRepeat: [
t5_ t5 + 1.
t3_ self concatenate: ('List') with: (t5).

input_ t3.
    t11 _ #('slider' 'light' 'sound' 'resistance' ).
    t11 _ t11 , #('-' 'tilt' 'distance' ).
t14_ t11.
    (t12 _ self ownerThatIsA: ScratchStageMorph) ifNotNil: [t12 scratchServer
            ifNotNil:
                [t13 _ t12 scratchServer sensorNames.
                t13 size > 0 ifTrue: [
t14_ self concatenate: (t11) with: ('-').
t11_t12 scratchServer sensorNames.
t14_ self concatenate: (t14) with: (t11).
]]].
t11_ #('').
t11_ self letter: (2) of: (t11).
t12_ self concatenate: (t11) with: (input).
t12_ self concatenate: (t12) with: (t11).
t14_ t14 asString.
t13_ self indexOf: (t12) startingAt: (0) in: (t14).
t13 = 0
ifTrue: [
output_ 0.
]
ifFalse: [
output_ self sensor: (input).
].

t2_ output.
t2 = 0
ifTrue: [
t2_ self varNamesMenu.
t11_ self concatenate: (quote) with: (t3).
t11_ self concatenate: (t11) with: (quote).

t2_ self indexOf: (t11) startingAt: (0) in: (t2).
t2 = 0
ifFalse: [
t2_ self reportVar: (t3).
].   
].

t2 = 0
ifFalse: [
t4_ self concatenate: (t4) with: ('/').
t4_ self concatenate: (t4) with: (t5). 
t7_ t7 + 1.
].
].


t2_ 0.
t8_ t4.
repeat_ 100.

t7 timesRepeat: [
t2_ t2 + 1.

t3_ 0.
t4_ 0.
trues_ false.
repeat timesRepeat: [
trues = false
ifTrue: [
t4_ t4 + 1.
t5_ self letter: (t4) of: (t8).
t5 = '/'
ifTrue: [
t3_ t3 + 1.
].

t3 = t2
ifTrue: [
trues_ true.
].
].
].


t6_ ''.
t4_ t4 + 1.
trues_ false.
repeat timesRepeat: [
trues = false
ifTrue:
[
t5_ self letter: (t4) of: (t8).
t6_ self concatenate: (t6) with: (t5).
t4_ t4 + 1.

temp_ self stringLength: (t8).
t4 > temp
ifTrue: [
trues_ true.
].
temp_ self letter: (t4) of: (t8).
temp = '/'
ifTrue: [
trues_ true.
].
].
].

t11_ self concatenate: ('List') with: (t6).

input_ t11.
    t11 _ #('slider' 'light' 'sound' 'resistance' ).
    t11 _ t11 , #('-' 'tilt' 'distance' ).
t14_ t11.
    (t12 _ self ownerThatIsA: ScratchStageMorph) ifNotNil: [t12 scratchServer
            ifNotNil:
                [t13 _ t12 scratchServer sensorNames.
                t13 size > 0 ifTrue: [
t14_ self concatenate: (t11) with: ('-').
t11_t12 scratchServer sensorNames.
t14_ self concatenate: (t14) with: (t11).
]]].
t11_ #('').
t11_ self letter: (2) of: (t11).
t12_ self concatenate: (t11) with: (input).
t12_ self concatenate: (t12) with: (t11).
t14_ t14 asString.
t13_ self indexOf: (t12) startingAt: (0) in: (t14).
t13 = 0
ifTrue: [
output_ 0.
]
ifFalse: [
output_ self sensor: (input).
].
t3_ output.


t3 = 0
ifTrue: [
t3_ self reportVar: (t11).
].


t4_ 1.
t7_ 0.
t9_ ''.
trues_ false.

repeat timesRepeat: [

trues = false
ifTrue: [
t4_ t4 + 1.
t5_ self letter: (t4) of: (t3).
t5 = '/'
ifTrue: [
t7_ t7 + 1.
]
ifFalse: [
t9_ self concatenate: (t9) with: (t5).
]. 

temp_ self stringLength: (t3).
t4 > temp
ifTrue: [
trues_ true.
].
t7 = 1
ifTrue: [
trues_ true.
].
].
].

t9 = t1
ifTrue: [
t10_ t3.
].

].
^ t10


You can now reach me on Twitter @johnnydean1_

Offline

 

#13 2010-08-09 10:31:29

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

^ I did that in Panther BTW!


You can now reach me on Twitter @johnnydean1_

Offline

 

#14 2010-08-09 11:28:21

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Convert a Script into a block!

*puzzled* im not getting this. no help srry  hmm

Offline

 

#15 2010-08-09 11:44:04

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

Can you convert everything after the
wait 0 secs

into a single block.

What it does

You enter a string
%s = hi

(Its t1)


it then sets a index variable to 0

it then checks 50 times by changing the index by 1
it then does (join (List) and (index) ) so it gets:
List1
List2
List3
...

It then sees if it exists over mesh, if not (=0) then it sees if it has it.

Then if it does, it records the index number.



It then checks the index numbers lists that its recorded e.g
List1 = /hi/item1/
List2 = /list2/item1/item2/


So as we entered hi it reports

/item1/
Get it, it searches the variables for your chosen list!


You can now reach me on Twitter @johnnydean1_

Offline

 

#16 2010-08-09 16:14:28

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Convert a Script into a block!

Please explain what you're bumping it FOR

Last edited by nXIII (2010-08-09 16:14:46)


nXIII

Offline

 

#17 2010-08-09 16:15:54

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

What bumps


You can now reach me on Twitter @johnnydean1_

Offline

 

#18 2010-08-09 16:18:16

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: Convert a Script into a block!

The ones you just deleted....?

Ah, has anyone seen that mov-- never mind....

Last edited by nXIII (2010-08-09 16:18:45)


nXIII

Offline

 

#19 2010-08-09 16:19:07

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Convert a Script into a block!

Well NXIII can you do it?


You can now reach me on Twitter @johnnydean1_

Offline

 

Board footer