< Scratch File Format (1.4)

Revision as of 07:19, 31 October 2018 by TemplatesFTW (talk | contribs) (Automated edit: Changed {{Forum Archive}}s to internal links)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

all scripts are converted to tuples before they are saved; each stack is converted to: (where () indicates an array)

(position (block1 block2 block3 ...))
each block is converted to:
(selector arg1 arg2 arg3 ...)
if the argument is a number, string, boolean, or color it is just included as the (n+1)th member of the array. If it is a block, the block is converted to a tuple and included in the correct place.

– nxIII, ar-post:1043186

For example, the script:

when I receive [message v]
set [var v] to ([sqrt v] of (100))
repeat until <(var)=[1]>
	wait ((3) - (2)) secs
	change [var v] by (-1)
say (join [hello ] [world])
if <<touching [Sprite1 v]?> or <key [space v] pressed?>> then
	broadcast [message v]
	switch costume to [costume1 v]

Gets encoded something like this:

    Point(20, 20.0),
        [<#EventHatMorph>, 'message'],
        [<#changeVariable>, 'var', <#setVar:to:>, [<#computeFunction:of:>, 'sqrt', 100]],
        [<#doUntil>, [<#=>, [<#readVariable>, 'var'], '1'],
                [<#wait:elapsed:from:>, [<#->, 3, 2]],
                [<#changeVariable>, 'var', <#changeVar:by:>, -1]
        [<#say:>, [<#concatenate:with:>, 'hello ', 'world']],
            [<#|>, [<#touching:>, <ScratchSpriteMorph(Sprite1)>], [<#keyPressed:>, 'space']],
                [<#broadcast:>, 'message'],
                [<#lookLike:>, 'costume1']

Where <#say:> represents the Squeak Symbol "say:", and [] is used interchangeably with () for tuples. (Whitespace added for clarity.)

See Also

  • Blockmaking FAQs to find information on block types (blockspecs)
  • A post by ScratchReallyROCKS explaining the anatomy of a Scratch block