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

#1 2010-01-24 14:59:18

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Help with Source Code mods...

Hi all,

I have a question for all you source code pros...

For my Scratch Resources site, I wanted thumbnails and snapshots to be generated for all sprites. The best way would be to do it with PHP, but since there's no sprite file format description released (!! Scratch team?  yikes  ) I can't.

So I had the idea of using the Scratch Source code - I just built my own server with windows XP, and I am sure it can be done to make it generate images say every day, using a modified version of the Scratch source code (and some PHP but I can do that on my own  smile  ).

Once I got to that, I thought it could also work to automatically export the scripts to an image. (It's already in Scratch, But I don't want to spend opening and clicking for hours every day. Could it be done automatically when Scratch opens a sprite?)

So, this is what I wanted:
• automatic thumbnail generation when I do something like

Code:

 Scratch.exe Scratchmod1.image "mysprite.sprite"

• automatic 'Export script snapshot' when I do something like

Code:

Scratch.exe Scratchmod2.image "spritewithscriptsinit.sprite"

I started to do this my self but I soon realized this is *far* beyond my capabilities/squeak knowledge...

Could some of you please help me?

Joren


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#2 2010-01-24 15:02:43

adriangl
Scratcher
Registered: 2007-07-02
Posts: 1000+

Re: Help with Source Code mods...

Yay, you finally asked XD If  only Jens were still here  big_smile


Scratchin' since 2007

Offline

 

#3 2010-01-24 15:22:57

filo5
Scratcher
Registered: 2008-01-08
Posts: 1000+

Re: Help with Source Code mods...

As far as I'm aware, Scratch stores costumes in bitmap format embedded in .sprite files, so first goal could be achieved without even touching Scratch; you'd only have to make a php script reading it.

Last edited by filo5 (2010-01-24 15:23:24)


Converting my Scratch projects to Python!

Offline

 

#4 2010-01-24 17:13:44

cds56
Scratcher
Registered: 2008-05-02
Posts: 500+

Re: Help with Source Code mods...

Jens isn't here?

I mean, he just posted last week, eh?


http://img192.imageshack.us/img192/909/meowdevlogo.pnghttp://i32.tinypic.com/pucti.png

Offline

 

#5 2010-01-24 17:38:04

billyedward
Scratcher
Registered: 2008-01-03
Posts: 500+

Re: Help with Source Code mods...

It sounds very doable... Would you want the script to save the images to a directory?


"I'd love to change the world, but they haven't released the source code yet."
Check out the latest version of Streak --> http://billy.scienceontheweb.net/Streak

Offline

 

#6 2010-01-25 04:42:32

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Help with Source Code mods...

Hi, JSO

You can access command the command line (parameters) in Squeak using a primitive in class SystemDictionary (it's documented there). If you start looking at class ScratchFrameMorph's #startup method, you'll also find examples of how to access the command line (e.g. for the 'presentation' flag). I guess this should get you going. Then the other task would be to run Squeak "headless", i.e. without opening a window. If I remember this right, there are some flags that you can set in the .ini file for this (you'll find documentation if you google SqueakVM, or go to the Squeak.org website). Good luck!


Jens Mönig

Offline

 

#7 2010-01-25 12:57:05

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Help with Source Code mods...

Squeak command line options
...
-headless
Tells Squeak to run without a main window. However, for allowing at least some access to Squeak, an icon is added to the system tray. If you double-click this icon, the Squeak window will show up again.
...

Ok, that's the first part. I thought I had the mod but it said: subscript out of bounds.
What does that error mean?

I'm not sure if I will get this done on my own but I'll see ^^

Joren


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#8 2010-01-25 13:07:35

coolperson
Scratcher
Registered: 2007-08-21
Posts: 1000+

Re: Help with Source Code mods...

I'm oviously not sombody that could do this- I was confused after the first sentnece. XD


Coolperson- 2012 National Vex Robotics Finalist!
http://www.scratch.mit.edu/ext/youtube/?v=sn7p84DQFyk

Offline

 

#9 2010-01-25 13:50:46

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Help with Source Code mods...

Oh Help.

I added

ScratchScriptEditorMorph saveScriptsToImage.

at the end of

ScratchFrameMorph>importSpriteOrProject:

but it just gives  a red error box with
Message not understood: saveScriptsToImage

I'm really a smalltalk noob and I don't always understand the special syntax  sad


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#10 2010-01-25 14:26:14

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Help with Source Code mods...

Who said jens was no longer with us? 0_o


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#11 2010-01-26 11:32:22

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Help with Source Code mods...

Hi JSO,

I think you can access the picture of the stage in its current form by calling

   workpane imageForm

from within ScratchFrameMorph.

If you're just interested in reading / exporting the thumbnail that's already stored in a saved Scratch project, you can extract that information by retrieving the entry associated with 'thumbnail' in the Scratch project's info dictionary. Look up method #extractInfoFrom: aByteArray in class ScratchFrameMorph. You can get the ByteArray needed by calling something like:

   | file filename project info thumb|
   filename := 'myScratchProject.sb'.
   file := FileStream readOnlyFileNamedOrNil: filename.
   project := self extractProjectFrom: file binary contentsOfEntireFile.
   info := self extractInfoFrom: project.
   thum := info at: 'thumbnail'

What you get is a bitmap (of class Form). Look there to find out how to save it!


Jens Mönig

Offline

 

#12 2010-01-26 11:53:22

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Help with Source Code mods...

But I wasn't trying to export the project thumbnail  sad

I want to export the scripts snapshot when loading a sprite file, and to export the sprite thumbnail on import...

Thanks a lot for your support though  smile

EDIT: I can export a sprite thumbnail with the stage image though.  I'll see. From one i've seen in importSpriteOrProject the .sprite file format is very similar to the .sb (or .scratch, it was somewhere in there too) file format.

Last edited by JSO (2010-01-26 11:53:39)


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#13 2010-01-26 12:05:23

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Help with Source Code mods...

Ah, okay. I guess you just need to make sure to send #saveScriptsToImage to the stage's (or sprite's) blocksBin, not to the stage/sprite itself. Try adding #blocksBin before the #saveScriptsToImage.


Jens Mönig

Offline

 

#14 2010-01-26 12:07:57

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Help with Source Code mods...

Wow, you're online. Thanks a lot  smile  I'll see what I can do.


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#15 2010-02-21 12:35:13

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Help with Source Code mods...

Oh well.

I just can't seem to do it, I'll spend some time reading online tutorials soon, but I really need this mod  sad

Can someone please, please do the script export thing for me?  smile  I will then learn some more squeak and do the sprite thumb export myself, that isn't really neccesary. My server is also ready now...

Thanks a lot in advance,
Joren


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#16 2010-03-05 01:41:18

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Help with Source Code mods...

I know a lot of php... Can I help?


Hai.

Offline

 

#17 2010-03-06 16:51:01

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Help with Source Code mods...

fg123 wrote:

I know a lot of php... Can I help?


Hai.

Offline

 

#18 2010-03-07 04:55:14

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Help with Source Code mods...

Idk  hmm  This Source Code mod has nothing to do with php though  hmm

And I'd love to let you help on the main site, but it's just really difficult to work together on PHP scripts as they need to run on the server and I'd need to give you the server login etc...

I might setup a testing server so all Scratchers uinterested in PHP can help... I'll see  wink

But still,
Can someone, please, please help me out with these rather small mods?


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#19 2010-03-07 10:21:51

adriangl
Scratcher
Registered: 2007-07-02
Posts: 1000+

Re: Help with Source Code mods...

JSO wrote:

Idk  hmm  This Source Code mod has nothing to do with php though  hmm

And I'd love to let you help on the main site, but it's just really difficult to work together on PHP scripts as they need to run on the server and I'd need to give you the server login etc...

I might setup a testing server so all Scratchers uinterested in PHP can help... I'll see  wink

But still,
Can someone, please, please help me out with these rather small mods?

Yeah, working together might cause some serious screw-ups  tongue


Scratchin' since 2007

Offline

 

#20 2010-03-07 14:33:31

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Help with Source Code mods...

Aww... Ah well...


Hai.

Offline

 

#21 2010-03-30 08:07:35

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Help with Source Code mods...

*bump*

Sorry to be bragging so much but could someone, please, please help me out with this?


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#22 2010-06-01 13:45:54

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Help with Source Code mods...

And *bump* another two months later  sad

Please, there are so many good Scratch modders out there, could someone *please* try to help me out with this problem?

You will of course be credited...


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#23 2010-06-02 11:31:28

shamrocker
Scratcher
Registered: 2009-03-19
Posts: 1000+

Re: Help with Source Code mods...

Wish I could help. I don't even know(yet) how to save the changes in the System Browser on a Mac yet!  yikes   sad


http://i46.tinypic.com/2s1b32e.png
respect the oxford comma

Offline

 

#24 2010-06-02 11:38:31

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: Help with Source Code mods...

shamrocker wrote:

Wish I could help. I don't even know(yet) how to save the changes in the System Browser on a Mac yet!  yikes   sad

Thanks anyway  wink

Please, someone...
I'll credit you everywhere if that makes you happy xD In my sig, on the site, in a project, in a thank-you forum thread xD


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#25 2010-06-02 11:49:37

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Help with Source Code mods...

I don't have any answers but I do have a few questions...are you running Scratch Resources off of your own server and are you planning to run Squeak server-side to create the thumbnails?


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

Board footer