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

#1 2010-10-03 10:20:17

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

Script Help

How do I make it so when I right click a script and it has these blocks:
When Flag Clicked
wait 27 sec

it offers a offers a option to export as blockspecs and inputs. For example that turns into:

('when %m clicked' #S #-)
('wait %n27% secs' #t #wait:elapsed:from: 1)


so I want to get a text equivalent of a script!


You can now reach me on Twitter @johnnydean1_

Offline

 

#2 2010-10-03 10:34:38

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Script Help

Add code to all of the block morphs to add their current value to a variable passed into a method, then add to the right click menu something that starts this process off and writes the result to a file.
Example (which is clearly not going to work):

Code:

exportBlocks
    | t1 |
    t1 _ String new.
    self script allBlocks do: [:t2 | t2 addCodeToString: t1].
    t1 writeToFileNamed: 'exported'

/* No comment */

Offline

 

#3 2010-10-03 10:40:00

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

Re: Script Help

TheSuccessor wrote:

Add code to all of the block morphs to add their current value to a variable passed into a method, then add to the right click menu something that starts this process off and writes the result to a file.
Example (which is clearly not going to work):

Code:

exportBlocks
    | t1 |
    t1 _ String new.
    self script allBlocks do: [:t2 | t2 addCodeToString: t1].
    t1 writeToFileNamed: 'exported'

Cant it work like Jens' XML exporter?


You can now reach me on Twitter @johnnydean1_

Offline

 

#4 2010-10-03 10:41:52

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: Script Help

Never seen that. Post a link please.


/* No comment */

Offline

 

#5 2010-10-03 11:18:10

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

Re: Script Help

Ok here


You can now reach me on Twitter @johnnydean1_

Offline

 

#6 2010-10-03 11:58:45

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

Re: Script Help

Well, I think project summaries already do that...


nXIII

Offline

 

#7 2010-10-03 12:04:08

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

Re: Script Help

Do they?


You can now reach me on Twitter @johnnydean1_

Offline

 

#8 2010-10-03 12:05:31

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

Re: Script Help

Yea, they use printCodeOn:indent:, I believe. You could make a modified version that just does the blocks and nothing else in the summary, or just shows it in a StringHolder.


nXIII

Offline

 

#9 2010-10-03 12:25:38

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

Re: Script Help

Yay thanks nXIII you saved me alot of code. Now can someone make something that exports all the costumes in a project!


You can now reach me on Twitter @johnnydean1_

Offline

 

Board footer