IPTSCRAE SCRIPTING LESSON ONE The Driver's Seat - Taking Control of Your Cyborg Iptscrae=Script Iptscrae is the name of the programming language used in the Palace system. Pig Latin experts will recognize it as being Pig Latin for "script". (Never say programmers don't have a sense of humor!) It is an interpreted language. This means that each program statement is converted to a code that can be understood by the computer just before the program statement is to be executed. Stacking it up! Iptscrae is a stack-oriented language. As an example let's add the numbers 1 and 2 together. To say this in Iptscrae it is "1 2 +". Imagine a restaurant plate-stacker which works like Iptscrae's stack: | 2 |The bottom plate (the first plate put on the pile or stack) has a "1" written on. The next plate up from the bottom (the second plate put on the pile or stack) has a "2" written on it. Now, if you want to add the numbers on the plates, you have to take them off the stack, one at a time, from the top to the bottom. This is referred to as Reverse Polish Notation (RPN). Although it is different from the order we are used to, to the computer, 1 2 + makes a lot of sense. What we are telling it is: 1. Put a 1 on the stack.This is a hard concept for people who've been exposed to other programming languages to understand, but once you get the hang of it, it's really very easy. Speaking the Language Any language, English, French or Japanese has a structure that is used to form "sentences". Iptscrae is no exception to this rule. It has a formal structure, or syntax used to create scripts. The largest components are Event Handlers and Atomlists. If you take a look at a cyborg.ipt file, you may see some or all of the following Event Handlers: ON SIGNON - Events that happen when you log onto a PalaceHandlers are "triggers" for making things happen. Programming statements must be inside one of the handlers or they will not work. The syntax for these handlers is:
Just as you need spaces in-between words in English to make sentences, you need spaces in-between statements in Iptscrae. A common mistake is: {atomlists and/or programming statements} Which will cause an error in Iptscrae. "{" and "}" are programming statements. They tell the interpreter "this is the beginning" or "this is the end" of an atomlist. They need to have space around them. So, the correct way is:{ atomlists and/or programming statements } Each writer has his or her own style. Some prefer to put everything in one atom list on one line. Some prefer to line up curlybraces so that pairs are easier to see in long scripts:{{ atomlists } and/or programming statements } Either will work, as long as your braces are paired and have "white space" (a space, tab or carriage return) around them. If you have a problem with a script not working, the first thing to check is that all of your braces are paired.Location, Location...Location! There are three basic places that the Iptscrae language is used: room scripts, cyborg scripts and in the text/chat box. Room Scripts: These are scripts that affect events in the Palace rooms. They live in the pserver.dat (AKA Mansion Script) file and are used by the Pserver. This series of classes does NOT cover room scripting, (except how it affects you as a user.) However, the programming skills you will learn are applicable to room scripts as well as your cyborg. Cyborg Script: The cyborg.ipt file is your Cyborg Script. It is used by your palace program, the one you use to log onto a Palace. The Text, or Chat Box: This is the place where you type in what you want to say. You can also type commands directly into this box by beginning your text with "/". For example, typing : /0 0 SETPOS in the text box will move you to the upper left corner of the screen. This method is handy for testing commands or very simple functions. We will be using it for that.We are the Borg! This series of classes is designed to give you control over your cyborg. As mentioned previously, every Palace user has a file in their Palace folder (directory) called CYBORG.IPT. It is a text file that can be opened and edited in any text editor. It's content can be altered. HOWEVER: the file must be saved as ASCII TEXT. If you are using a word processor, make sure you choose the "text only" option when you save the file! Word processors format text in their own way, inserting special codes for things like bold and margins. One sure way to kill your borg is to save it out in the word processor's format. Trigger Happy! No, we aren't going to shoot anyone...ZAP! them, perhaps, but no lethal damage is allowed! What we're going to look at are "trigger conditions". These are conditions that cause something to happen, just like pulling the trigger on a gun causes it to fire a bullet. These are the most common types of routines that you will find in cyborg scripts. The format is: { -routine code- } -trigger condition- IF The "trigger condition" is simply the statement of what has to be true before the routine will be triggered- or will run. The most common form it will take is:{ code } CHATSTR "test"==IF which will cause the code inside the curlybraces to execute IF the CHATSTR is equal to the word "test". CHATSTR is a special variable used in Iptscrae. It is equal to whatever is "said". So, if someone (including you) says "Hi there!" the CHATSTR variable (at that time) is equal to "Hi there!"You should note that "==", which compares CHATSTR to the word "test" is not case sensitive. This mean that "test", "Test", "TEST" and "tESt" will all match. Also, be careful! "=" and "==" are two DIFFERENT commands in Iptscrae. The first one means, "MAKE equal to" and is called an assignment operator. The second one means "IS equal to" and is a comparison operator. Moving In Without a UHaul To put a script into your cyborg, first determine which handler it has to be in. It is very important that you put your new routines in the right place in the right handler. Simply copy all of the text from the first "{" to the end of the word "IF", and paste it into your cyborg in the appropriate handler. Be SURE you do not paste it inside of another routine. For instance: ON OUTCHAT { { new routine } CHATSTR "test"==IF { zap routine } CHATSTR "zap"==IF } is the correct way, with two routines in the OUTCHAT handler. The INcorrect way would be:ON OUTCHAT { { { new routine } CHATSTR "test"==IF zap routine } CHATSTR "zap"==IF } This puts your new routine INSIDE the zap routine, and it won't even be checked unless the zap routine is triggered first- and then it wouldn't ever be true, since the CHATSTR needed to trigger it would be "zap" instead of "test".HOMEWORK: 1. Find your cyborg file and save a backup copy. You can either save it under a different name or put a copy in another directory/folder. Make sure that you have a "clean" file. If you have changed your cyborg file, or gotten scripts from someone or someplace else (like Dr. X's House,) you will need to find your original cyborg.ipt and reinstall it. 2. Edit your cyborg.ipt and put the following routine in the INCHAT handler:
CHALLENGE: Challenges are not homework. You may or may not do them; it's up to you. They are to give you more to do if you find that the homework was too easy, or to help advance your programming knowledge. This week's challenge is to look at the original cyborg.ipt file. It should contain several routines in several Handlers that you can look at and analyze. See if you can figure out what each one does and how it does it. NOTES: 1. For more information about Iptscrae, go to the main Palace web site: http://www.thepalace.com and click on the TECH button. On the Tech page, choose "online manuals". On the manuals page, choose Iptscrae. There is a LOT of information here. You may want to bookmark this site for future reference. 2. If you have not already visited Dr. X...then by all means do so! It is located at http://www.botzilla.com. This is a good-sized site with lots of scripting tips and hints. 3. I can't emphasize enough how important it is to BACK UP your files! Before you make changes in your cyborg.ipt file, make a back up of it. That way, if something goes wrong, you can start over again. You should also back up your prop file (palace.prp) on a regular basis. <Previous> <Iptscrae> <Next> |