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

#1 2010-03-27 20:18:55

graham7sarah9
Scratcher
Registered: 2009-07-19
Posts: 28

StarScriptor

Hello. StarScriptor is a very new, but advanced scripting language made on Scratch. It has a specific use, and because of that, it has several features most scripting languages on Scratch don't have. It has if statements, buttons, animations (up to 4 frames) that can be set to a speed, a textbox already programmed, and many other features.
Here is a link to my project: http://scratch.mit.edu/projects/graham7sarah9/917206

I can't imagine how hard it would be to understand my scripting language without a guide, so I'm making this into one.

==============================Format============================================
The format of a command needs to be error-less, or the program will freeze. Any typos will send the program on a wild goose chase.
So, the first thing you should know is that this is a parsed language, meaning that commands and their arguments will be on the same line. The next thing you should know is that you can put multiple commands on the same line. Finally, all code goes into the list called "Code".
So the format for each command is:

Code:

/Command/[Argument1][Argument2][Argument3]...

Don't put the ... at the end, but the amount of arguments may vary.
==============================Commands & Syntax===============================
Expression
This is an expression going from left to right (no PEMDAS).
There are brackets around the expression and around each number/operation. Say we wanted [[[8*3]+4]*2]. Then, we would type:

Code:

/Expression/[[8][*][3][+][4][*][2]]

Which would end up as 56. As for the operations:
*=multiplication
+=addition
-=subtraction
/=division
Use this format any time I put [Expression] and don't put the /Expression/ at the beginning.
Note: Values in expressions and variables can be strings.
Setvar
Variables are quite advanced in StarScriptor. What I mean by that is that they have a few cool features. When you set a variable, if it doesn't exist, it will create that variable. Here is the format:

Code:

/Setvar/[Variable's name][Expression]

So, say I wanted to set a variable awesome to 7 (this will demonstrate how to set a number without more than 1 number). I would type this in:

Code:

/Setvar/[awesome][[7]]

And there we have it.
Value
Every variable and its name are stored in two lists: VarNames and VarValues. It's fairly simple to look a value up. It goes like this:

Code:

/Value/[%Variable's name]

For example, if we wanted to look up the variable awesome from above, we would type:

Code:

/Value/[%awesome]

Then, it should come out as 7. The reason I have the % at the beginning is because it can be used in an expression. Say you wanted to find awesome plus eight. You would type:

Code:

/Expression/[[%awesome][+][8]]

It should come up with 15.
If
There always has to be a way to look at what you just researched. That comes in later, but with the if command, you can still compare. There are three ifs: math, condition, and  boolean.
Math
Math consists of two expressions and an equal sign. The format is a bit odd, but rest assured, I'm making no mistake in forgetting []s.

Code:

/If/[Math][Expression[=]Expression]

So, say we wanted to see if 5+7=2*6. We would write:

Code:

/If/[Math][[5][+][7][=][2][*][6]]

If the statement is true, it will look at the next command on the line. If it isn't true, it will go to the next line. You might want to make it:

Code:

/If/[Math][[5][+][7][=][2][*][6]]/Textbox/[Tester: It worked!]
/Textbox/[Tester: The program is over]/End/

That's a bit more advanced, but the rest will be covered later.
Boolean
This will check to see if a variable is set to True. If it's not, the program will skip to the next line. This is helpful in buttons (which will be covered later on). The format is:

Code:

/If/[Boolean][Variable's name]

No need for the % in the variable's name.
Condition
It checks if a condition (or event marker) has been created. I'll talk about them in the next segment.
Addcon
Conditions are event markers; when the code reaches a certain line, it can remember that it's been there. The way it works is:

Code:

/Addcon/[Condition's name]

This is self-explanatory. This event will be saved in memory.
IfCondition
The way I've made it, you can check multiple conditions at once. The format is:

Code:

/If/[Condition][[Condition1][Condition2][Condition3]...]

So, we might have a situation like this:

Code:

/Addcon/[The Awesome Condition]
/Addcon/[The Cool Condition]
/Randomcommand/[Randomargument]
/Randomcommand/[Randomargument]
/Randomcommand/[Randomargument]
/If/[Condition][[The Awesome Condition][The Cool Condition]]

and it would look at the rest of the line because both of those conditions have been noted.
Case
If you use the commands Expression, Value, MouseX, or MouseY, they will be remembered until the next command. If the command is anything other than Case, the results will be forgotten. The format is like so:

Code:

/Case/[Expression][(In)Equality1(In)Equality2]

This is an odd command. Say you wanted to check if 3 was greater than or equal to 4. Then, you would use Expression like so:

Code:

/Expression/[[4]]
/Case/[[3]][>=]

It's deciding if 3 >= 4.
The case command works like an if statement. For example, you could make something like this:

Code:

/Value/[awesome]
/Case/[[3]][>>]/Setline/[[17]]
/Case/[[3]][==]/Setline/[[34]]
/Case/[[3]][<<]/Setline/[[117]]

Setline
Setline is pretty simple; it consists of a small amount of code:

Code:

/Setline/[Expression]

And it will jump there. If you wanted to jump to line 52:

Code:

/Setline/[[52]]

or:

Code:

/Setline/[[26][*][2]]

which would skip to line 52.
Findtag, Tag, and Resume
When you jump somewhere, sometimes:
a) you don't know what line to go to
b) you have to record where you came from.
And because of that, you need to use Findtag. In this sample of code, the numbers next to the commands are line numbers.

Code:

21./Randomcommand/[Randomargument]
22./Randomcommand/[Randomargument]
23./Fintag/[Skip&ComeBack]
24./Randomcommand/[Randomargument]
25./Randomcommand/[Randomargument]
26./Randomcommand/[Randomargument]
27./Setline/[[32]]
28./Tag/[Skip&ComeBack]
29./Randomcommand/[Randomargument]
30./Randomcommand/[Randomargument]
31./Resume/

What this will do is to get to line 23, and skip over to the tag that says Skip&ComeBack. It will execute the code after that, then, when it hits line 31, it will go to line 24 (the line right after findtag). When it hits line 27, it will skip past this tangled example.
You might be saying: "Why jump around so much?" Well the reason is that when it comes to the player, you may need a tangled mess to have a coherent game.
---------------------------------------------------------------------------------------------------------------------
In total, there are 23 (and counting) commands. I don't have the time or the patience to go through every last one all at once, so I'll just write more later.

Last edited by graham7sarah9 (2010-03-30 11:41:54)

Offline

 

Board footer