Special Commands

 

Most command are preceded with the name of the character followed by “>” and a space, for example, “merlin> blink”. Below are some special commands that require extra information supplied by your child.  Some are global (affecting all characters), so they are not prefaced with the character’s name. Type case (lower or upper) does not matter.

 

Pause (seconds) --- “(seconds)” should be replaced by a number. This is a pause before continuing program execution.

 

Interval (seconds) --- “(seconds)” should be replaced by a number. This is the time waited between action commands. Since some commands take a long time to complete, making the interval too short will interfere with subsequent commands. The default interval is 5 seconds between commands.

 

Sequential (true/false) --- “(true/false)” is replaced by true or false. The default is true. If true, then the commands are followed sequentially, one by one down the list of script lines. If false the commands are executed as fast as possible so that characters may be able to perform simultaneous actions. Look at the “lets_go_nuts.csp” script. There are three sequential statements in that script, two of them are “true”, and one is “false”. Try changing the false to true, and see that now each character does his do loop seperatly in the order of the script. Change it back to false and they go nuts!

 

Show (character) --- “(character)” should be replaced by the name of a character, e.g. “Merlin”, “Plany”, etc. The names can be seen in the Actions window. Multiple characters can be shown simultaneously. In a script if you refer to a character in a command, for example, “plany> tickle 2” and Plany was not previously visible, it will be shown automatically.

 

Hide (character) --- “(character)” should be replaced by the name of a character, e.g. “Merlin”, “Plany”, etc. The names can be seen in the Actions window.

 

Hide all  --- Hides all characters.

 

Character> Speak (words) --- In the Script window, “(words)” should be replaced by any word or words or funny sounding letters! If you have created an audio file and placed it in the “wav” directory (this is done automatically when audio recording is done in Merlin Programmer for Kids), you can use this file for lip-syncing. Simply place the filename after the Speak command. For example, the following line will have Merlin lip-sync the speech in the wave file “my_voice.wav”.

 

Merlin> Speak my_voice.wav

 

Look at the script file “silly voice.csp” for a functional example.

 

 

Character> MoveTo X,Y   --- In the Script window, the “X ,Y”  must be replaced by screen coordinates, for example, “132, 200”. At the bottom right of the main program window the X,Y coordinates of the mouse cursor and the character are displayed so that your child can drag the character (mouse down on the character, press left button, and move) or move the mouse cursor to a particular location on the screen where he/she wants the character to move. He/she can then use those coordinates in the command.

 

Character> MoveTo random   --- the computer will randomly choose the X,Y coordinates.

 

Character> MoveTo (character)   --- In the Script window, the “(character) “ should be replaced by the name of a character, for example “merlin> moveto plany”. The first character will move to the second character’s position.

 

The MoveTo commands can have a speed parameter appended to them that will adjust the speed of the movements. The choices are slowest, slower, slow, medium, fast, faster, and fastest. For example, “merlin> moveto random fastest” would move Merlin to a random location very fast.

 

 

Character> StopMoving   --- the character will stop moving ununconditionally..

 

Character> CharPos (X,Y) --- In the Script window, the “(X ,Y)”  must be replaced by screen coordinates, for example, “132, 200”. This command quickly sets the character to a new location on the screen. If the character is hidden the repositioning will occur without showing the character.

 

Character> Tickle (size) ---  In the Script window, the “(size)”  must be replaced by a number indicating how big a wiggle the character will make.

 

Character> CharSize (W,H) --- In the Script window, the “(W,H)”  must be replaced by desitred width, height of the character in pixels. The current and default settings are reported when this command is double clicked in the Merlin Actions window with the Show me item selected.

 

Report (seconds) --- In the Script window, the “(seconds)” should be replaced by a number of seconds. For those commands where the character counts down or waits for something to happen, the character typically repeats some phrase every number of seconds. This command should precede those commands to have an effect. The default is every 5 seconds.

 

Character> Waitfor Time=(H:M AM/PM) --- The “(H:M AM/PM)” should be replaced by a valid time, as shown at the bottom left in the information panel of the program. For example, “2:31 AM” or “10:02 PM”. The character will continually say “I am waiting for….”, until the condition (time is reached) is met or exceeded. You can add the word “quiet” to the end of the command to stop the chatter, otherwise the character counts down every Report number of seconds (see Report command).

 

Character> Waitfor Time=(minutes) --- In the Script window, the “(minutes)” should be replaced by a number of minutes, which can be fractional; for example “1.5”. The character will continually say “I am waiting for….”, until the condition (countdown to zero) is met or exceeded. You can add the word “quiet” to the end of the command to stop the chatter, otherwise the character counts down every Report number of seconds (see Report command).

 

Character> Waitfor Key=(letter) --- In the Script window, the “(letter)” should be replaced by the letter of a key on the keyboard. The character will continually say “I am waiting for….”, until the condition (pressing the key) is met or exceeded. You can add the word “quiet” to the end of the command to stop the chatter, otherwise the character counts down every Report number of seconds (see Report command). Double clicking on the character will cancel the wait and go to the next script statement.

 

Character> Waitfor Key=anykey --- The character will continually say “I am waiting for any key to be pressed.”, until the condition (pressing any key) is met. You can add the word “quiet” to the end of the command to stop the chatter, otherwise the character counts down every Report number of seconds (see Report command). Double clicking on the character will cancel the wait and go to the next script statement. You can test for the key pressed with the If statement (see below).

 

Character> Waitfor Listen=anywords --- The character will simply wait for something to be said. A small text box below the character will indicate this. When the condition is met, that is, one of the voice commands is spoken and understood by the character, execution will continue. The character thinks the words that it is waiting for every Report number of seconds (see Report command). When it recognizes a word or phrase then it speaks that word or phrase. You can add the word “quiet” to the end of the command to stop the repeat. Double clicking on the character will cancel the wait and go to the next script statement. You can test for the spoken word or words with the If statement (see below). Voice commands that will be checked for are introduced using the If statement. Speaking “cancel script” will cancel the script.

 

Character> Waitfor Collide=(character) --- In the Script window, the “(character)” should be replaced by the name of a character. The character will wait for the two characters to overlap each other on the screen before execution will continue. The character will continually say “I am waiting for….”, until the condition (characters bump each other) is met or exceeded. You can add the word “quiet” to the end of the command to stop the chatter, otherwise the character counts down every Report number of seconds (see Report command). Double clicking on the character will cancel the wait and go to the next script statement. See the “collide.csp” script for a possible use of this command. In that script Sequential is set to false otherwise the Waitfor Collide command is not executed until after the characters stop moving. You would have drag the characters together to satisfy the overlap condition.

 

Character> Waitfor Collide=anybody --- The character will wait for any other character to overlap it on the screen before execution will continue. The character will continually say “I am waiting for….”, until the condition (characters bump each other) is met or exceeded. You can add the word “quiet” to the end of the command to stop the chatter, otherwise the character counts down every Report number of seconds (see Report command). You can test which characters bumped with the If statement (see below).

 

Character> Waitfor GetOff=(character) --- In the Script window, the “(character)” should be replaced by the name of a character. The character will wait until the two characters are not overlapping on the screen before execution will continue. The character will continually say “I am waiting for….”, until the condition (characters to get off each other) is met or exceeded. You can add the word “quiet” to the end of the command to stop the chatter, otherwise the character counts down every Report number of seconds (see Report command). Double clicking on the character will cancel the wait and go to the next script statement. See the “collide.csp” script for a possible use of this command..

 

 

Do  …..  Loop (number) ---  These two commands are always used together. First insert the Do command in the Script window, then insert other commands, such as “Moveto random”, and finally insert the Loop (number) command, where “(number)” is replaced by the number of times the commands within the loop will be executed.  For example,

 

Do

Moveto random

Speak  I moved here!

Loop 3

 

This script will repeat the two commands within the loop 3 times.

 

If … then, elseif … then, else, endif  --- These commands are used to check whether something has happened and then depending on the what happened to perform some commands. In the following example Merlin waits for a key press then depending on which key is pressed, the proper response is spoken. The commands between else and endif are executed if the key pressed was not a, b and c. You may put a do loop within the If statements. You may only have one If .. endif in a script.

 

There are three conditions that can be checked for with the If statement. They are

 

1.      Key input. In the following example Merlin waits for a key and says something depending on which key was pressed.

 

Merlin> waitfor key=anykey

 

If  key=a then

Merlin> speak the “a” key was pressed

 

Elseif key=b then

Merlin> speak the “b” key was pressed

 

Elseif key=c then

Merlin> speak the “c” key was pressed

 

Else

Merlin> speak some other key was pressed

Endif

 

 

2.      Character collisions. In the following example Max and Peedy start jumping around on the screen and Merlin waits for either character to bump him; then depending on which character bumped him, the proper response is spoken.

 

interval 0

sequential false

 

do

max> moveto random

loop 50

 

do

peedy> moveto random

loop 50

 

merlin> waitfor collide=anybody

 

interval 1

sequential true

 

if collision=max and merlin then

merlin> speak max you bumped me!

max> speak sorry

 

elseif collision=peedy and merlin then

merlin> speak peedy you bumped me!

peedy> speak sorry

 

endif

 

 

 

3.      Voice input. In the following example Merlin waits for something to be said.  The words that he will wait for are the ones checked for in the If…endif statement. When Merlin recognizes one of the voice commands, the if statement will be executed and the response dictates what will follow.

 

 

interval 0

merlin> charpos 500,500

show merlin

 

merlin> waitfor listen=anywords quiet

 

if listen=hello then

merlin> speak Hi to you, too!

 

elseif listen=goodbye then

 

merlin> speak Goodbye.

hide merlin

 

elseif listen=Where is Max? then

 

merlin> speak He is coming now!

max> charpos 600,100

max> speak Hello guys!

max> speak please press the "g" key and I will get tickled!

max> waitfor key=g

max> tickle 3

endif

 

 

 

See the scripts “if_collision.csp” , “if_listenup.csp” and “choose_guys.csp” for functional examples

 

 

Goto (Label) --- “(Label)” should be replaced by a special identifier (must be label1, label2, label3…label10) on any line; then, for example, the command Goto label1 will cause execution to jump to the line immediately following the label, label1.  In the following script, Merlin waits for the spoken words goodbye or hello. If hello is spoken execution repeats because it jumps back to the line following label1, but if goodbye is spoken, execution eventually ends.

 

interval 1

 

label1

merlin> waitfor listen=anywords quiet

 

if listen=goodbye then

 

sound drumroll

 

elseif listen=hello then

 

sound applause

goto label1

 

endif

 

sound blip

 

 

 

See “Goto.csp” for this functional script.