The file format for 2.0 projects should be XML, and should work similar to snap (the sequel to BYOB)
The top-level code will be
<project name=project name>
<notes>
project notes
</notes>*
<thumbnail>
base-64 encoded image
<blocks>
custom block definitions, see below
</blocks>*
<stage background=stage background number>
stage declaration, see below
</stage>
<sprites>
sprite declarations, see below
</sprites>
<var-watcher var=variable name x=watcher x y=watcher y readout=readout (normal, large or slider) slider-min=slider min** slider-max=slider max**/>*
...
<list-watcher list=list name x=watcher x y=watcher y w=width h=height/>*
...
</project>
*omitted if there are none
**only for sliders
Custom blocks: (confirmed 2.0 feature)
<blocks>
<block-definition catograry=catograry (motion, control, ect)scope=scope* type=either stack, reporter or Boolean>
<block-name>
first bit of block name <block-input type=input type** default=default value>input name</block-input>second bit of block name ...
</block-name>
<script hat='block-definition'>
block script, see below
</script>
</block-definition>
...
</blocks>
*what objects can use it, either sprites, stage or global
**either number, string or Boolean (or drop-down if it is implemented)
Stage/sprite declarations:
<stage background=stage background number>
<variables>
variable declarations, see below
</variables>
<media>
media declarations, see below
</media>
<scripts>
scripts, see below
</scripts>
</stage>
<sprites>
<sprite name=sprite name x=x position y=y position dir=sprite direction costume=costume number hidden='hidden'* rotate=rotation style either normal, flip or none>
<variables>
variable declarations
</variables>
<media>
media declarations
</media>
<scripts>
scripts
</scripts>
</sprite>
...
</sprites>
*omit if sprite is shown
Variable declarations:
<variables>
<variable name=var name>value</variable>
...
<list name=list name>
<item>value,</item>
...
</list>
...
</variables>
*omit if watcher is hidden
**only if readout is slider
Media:
<media>
<costume name=costume name rotationx=costume center x* rotationy=costume center y*>
<text x=x position of text layer* y=y position of text layer* size=text size font=text font>text content</text>
...
<image>base-64 encoded image</image>
</costume>**
...
<sound name=sound name>base-64 encoded sound</sound>
...
</media>
* relative to top-left corner of costume
**on the stage it is background not costume and there is no rotation center
Scripts:
<scripts>
<script hat=script hat* input=hat block input**>
<block type=stack, report or Boolean>first bit of block name, for example 'move'<input type=input type***>value****</input>2nd bit of block name, for example 'steps' ...<c-mouth>If it is a c-block, script goes in here. If not, omit the c-mouth bit</c-mouth></block>
...
</script>
...
</scripts>
*either 'green-flag', 'receive','key-pressed'or 'sprite-clicked'
**only for receive and key-pressed
***either 'number', 'string', 'reporter','Boolean', 'drop-down' , 'variable-name' 'list-name'.
****if it is a Boolean or reporter this will be another block tag.
Here is a DTD:
<!DOCTYPE project [ <!ELEMENT project (notes?, blocks?, stage, sprites, (var-watcher|list-watcher)*)> <!ELEMENT notes (#PCDATA)> <!ELEMENT thumbnail (#PCDATA)> <!ELEMENT var-watcher (#EMPTY)> <!ELEMENT list-watcher (#EMPTY)> <!ATTLIST var-watcher var-name IDref #REQUIRED> <!ATTLIST var-watcher x CDATA #REQUIRED> <!ATTLIST var-watcher y CDATA #REQUIRED> <!ATTLIST var-watcher readout (normal|large|slider) normal> <!ATTLIST var-watcher slider-min CDATA 1> <!ATTLIST var-watcher slider-max CDATA 10> <!ATTLIST list-watcher list-name IDref #REQUIRED> <!ATTLIST list-watcher x CDATA #REQUIRED> <!ATTLIST list-watcher y CDATA #REQUIRED> <!ATTLIST list-watcher w CDATA 95> <!ATTLIST list-watcher h CDATA 115> <!ELEMENT blocks (block-definition*)> <!ELEMENT block-definition (block-name, script)> <!ELEMENT block-name ((#PCDATA|block-input)*)> <!ELEMENT block-input (#PCDATA)> <!ATTLIST block-definition catograry, (motion|control|looks|sensing|operators|pen|sound|variables|lists|other) #REQUIRED> <!ATTLIST block-definition scope (sprites|stage|global) global> <!ATTLIST block-definition type (stack|reporter|boolean) stack> <!ATTLIST block-input type (number|string|boolean) string> <!ATTLIST block-input default CDATA #IMPLIED> <!ELEMENT stage (variables, media, scripts)> <!ELEMENT sprites (sprite*)> <!ELEMENT sprite (variables, media, scripts)> <!ATTLIST stage background CDATA #REQUIRED> <!ATTLIST sprite name ID #REQUIRED> <!ATTLIST sprite x CDATA #REQUIRED> <!ATTLIST sprite y CDATA #REQUIRED> <!ATTLIST sprite costume CDATA #REQUIRED> <!ATTLIST sprite hidden (hidden|shown) shown> <!ATTLIST sprite rotation (normal|flip|none) normal)> <!ELEMENT variables (variable*, list*)> <!ELEMENT variable (#PCDATA)> <!ELEMENT list (item*)> <!ELEMENT item (#PCDATA)> <!ATTLIST variable name ID #REQUIRED> <!ATTLIST list name ID #REQUIRED> <!ELEMENT media ((costume*|background*),sound*)> <!ELEMENT costume (text*,image)> <!ELEMENT background (text*, image)> <!ELEMENT text (#PCDATA)> <!ELEMENT image (#PCDATA)> <!ELEMENT sound (#PCDATA)> <!ATTLIST costume name ID #REQUIRED> <!ATTLIST costume rotationx CDATA #REQUIRED> <!ATTLIST costume rotationy CDATA #REQUIRED> <!ATTLIST background name ID #REQUIRED> <!ATTLIST text x CDATA #REQUIRED> <!ATTLIST text y CDATA #REQUIRED> <!ATTLIST text size CDATA #REQUIRED> <!ATTLIST text font CDATA #REQUIRED> <!ATTLIST sound name ID #REQUIRED> <!ELEMENT scripts (script*)> <!ELEMENT script (block*)> <!ELEMENT block ((#PCDATA|input|c-mouth)*)> <!ELEMENT input (#PCDATA|block)> <!ELEMENT c-mouth (block*)> <!ATTLIST script hat (green-flag|receive|key-pressed|sprite-clicked|block-definition) green-flag> <!ATTLIST script input CDATA #IMPLIED> <!ATTLIST block type (stack|reporter|boolean) stack> <!ATTLIST input type (number|string|boolean|drop-down|variable-name|list-name)> ]>
There would be an application to convert old .sb files into this format.
Advantages:
You could make a scratch project in notepad without scratch installed!
Smaller file size,
Recognized by tons of programming languages,
Easy to store on the internet,
You can copy scripts, costumes, and even entire sprites to another scratch window,
Easy to read and write by humans,
Projects will load faster.
Last edited by joefarebrother (2012-04-13 06:10:57)
Offline
That would be so great!
Offline
I agree;; this would be bloody excellent. Especially with the custom blocks, so then there could be a block repository like the Library where you could add blocks really easily.
Offline
SJRCS_011 wrote:
I like it.
especially editing using notepad
Almost like text based Scratch!
veggieman001 wrote:
I agree;; this would be bloody excellent. Especially with the custom blocks, so then there could be a block repository like the Library where you could add blocks really easily.
Yay, the Block Library won't have to die with an update!
Except I'm 99.9% sure this won't make it into the 2.0 release. Maybe sometime later though!
Last edited by scimonster (2012-02-12 11:36:15)
Offline
maybe for the scripts section we could use the block plugin syntax.
As for the DTD, why not do something like the HTML doctypes, so like this:
<!DOCTYPE SCRATCH public "scratch.mit.edu/dtd/Scratch_2-0/final.dtd">
where "final.dtd" contains all of this:
<!ELEMENT project (notes?, blocks?, stage, sprites)> <!ELEMENT notes (#PCDATA)> <!ELEMENT blocks (block-definition*)> <!ELEMENT stage (variables, media, scripts)> <!ELEMENT sprites (sprite*) <!ATTLIST stage background CDATA #REQUIRED> <!ELEMENT block-definition (block-name, script)> <!ELEMENT block-name ((#PCDATA|block-input)*)> <!ATTLIST block-definition catograry, (motion|control|looks|sensing|operators|pen|sound|variables|lists|other) #REQUIRED> <!ATTLIST block-definition scope (sprites|stage|global) global> <!ATTLIST block-definition type (stack|reporter|boolean) stack> <!ATTLIST block-input type (number|string|boolean) string> <!ATTLIST block-input default CDATA #IMPLIED> <!ELEMENT variables (variable*, list*)> <!ELEMENT media ((costume*|background*),sound*)> <!ELEMENT scripts (script*)> <!ELEMENT sprites (sprite*)> <!ELEMENT sprite (variables, media, scripts) <!ATTLIST sprite name ID #REQUIRED> <!ATTLIST sprite x CDATA #REQUIRED> <!ATTLIST sprite y CDATA #REQUIRED> <!ATTLIST sprite costume CDATA #REQUIRED> <!ATTLIST sprite hidden (hidden|shown) shown> <!ATTLIST sprite rotation (normal|flip|none) normal)> <!ELEMENT variable (#PCDATA)> <!ELEMENT list (item*)> <!ELEMENT item (#PCDATA)> <!ATTLIST variable name ID #REQUIRED> <!ATTLIST variable watcher (shown|hidden) hidden> <!ATTLIST variable watcherx CDATA #REQUIRED> <!ATTLIST variable watchery CDATA #REQUIRED> <!ATTLIST variable readout (normal|large|slider) #REQUIRED> <!ATTLIST variable slidermin CDATA 1> <!ATTLIST variable slidermax CDATA 10> <!ATTLIST list name ID #REQUIRED> <!ATTLIST list watcher (shown|hidden) hidden> <!ATTLIST list watcherx CDATA #REQUIRED> <!ATTLIST list watchery CDATA #REQUIRED> <!ATTLIST list watcherw CDATA 95> <!ATTLIST list watcherh CDATA 115> <!ELEMENT costume (text*,image)> <!ELEMENT background (text*, image)> <!ELEMENT text (#PCDATA)> <!ELEMENT image (#PCDATA)> <!ATTLIST costume name ID #REQUIRED> <!ATTLIST costume rotationx CDATA #REQUIRED> <!ATTLIST costume rotationy CDATA #REQUIRED> <!ATTLIST background name ID #REQUIRED> <!ATTLIST text x CDATA #REQUIRED> <!ATTLIST text y CDATA #REQUIRED> <!ATTLIST text size CDATA #REQUIRED> <!ATTLIST text font CDATA #REQUIRED> <!ELEMENT script (block*)> <!ELEMENT block ((#PCDATA|input|c-mouth)*)> <!ELEMENT input (#PCDATA|block)> <!ELEMENT c-mouth (block*)> <!ELEMENT blank-input EMPTY> <!ATTLIST script hat (green-flag|receive|key-pressed|sprite-clicked|block-definition) green-flag> <!ATTLIST script input CDATA #IMPLIED> <!ATTLIST block type (stack|reporter|boolean) stack> <!ATTLIST input type (number|string|boolean|drop-down|variable-name|list-name)>
("final" could be "beta" for beta version, "alpha" for alpha version, etc.)
Last edited by SJRCS_011 (2012-02-14 20:02:19)
Offline
SJRCS_011 wrote:
maybe for the scripts section we could use the block plugin syntax.
well how would you define c-blocks?
Offline
This sounds brilliant! It will work like the Text Based Scratch idea that many users want, but instead of having to program a complicated new mode into 2.0, they can just change their code to be human-readable XML files! That way, advanced users can have the experience of text-based coding, without the risk of confusing newer users!
I wholeheartedly support!
Offline
File size is an issue. Binary is more efficient than ASCII--the file limit of 10 MBs would store so much less.
Offline
bobbybee wrote:
File size is an issue. Binary is more efficient than ASCII--the file limit of 10 MBs would store so much less.
How about at least having it as an option?
Offline
That would work well. Really well.
Offline
bobbybee wrote:
File size is an issue. Binary is more efficient than ASCII--the file limit of 10 MBs would store so much less.
Well, the 10MB limit is going to be raised...
Offline
bobbybee wrote:
File size is an issue. Binary is more efficient than ASCII--the file limit of 10 MBs would store so much less.
i'm not sure - the binary object serialization is actually not so efficient...
did you guys ever notice scratch knows about every time we saved the project?!
Offline
I support!
Offline
Offline
roijac wrote:
bobbybee wrote:
File size is an issue. Binary is more efficient than ASCII--the file limit of 10 MBs would store so much less.
i'm not sure - the binary object serialization is actually not so efficient...
did you guys ever notice scratch knows about every time we saved the project?!
If these things were improved, the file sizes would go down. A lot.
Offline
You could also save parts of your project (like some sprites of scripts) in the exact same format just trimmed down to the bit you need.
Offline
bump
Offline
joefarebrother wrote:
SJRCS_011 wrote:
maybe for the scripts section we could use the block plugin syntax.
well how would you define c-blocks?
Then use an adapted version that is nonetheless the same or very similar to the syntax
Offline
SJRCS_011 wrote:
joefarebrother wrote:
SJRCS_011 wrote:
maybe for the scripts section we could use the block plugin syntax.
well how would you define c-blocks?
Then use an adapted version that is nonetheless the same or very similar to the syntax
well my only issue is performance: if the scripts were in a different syntax to the rest, there will have to be extra code to parse this syntax and validate it, then write it back when something is saved, meaning it will take longer and scratch itself will need a larger file size. If the scripts were XML, all syntax errors will be caught by the XML parser and then the structure is quick and easy to navigate and therefore quick to load projects.
Offline