IPTSCRAE SCRIPTING LESSON FOUR
Communication is the main purpose of the Palace software. The most common types of communications take place between two (or more) users, in the form of "talking" to each other. Generally, this is done by typing what the user wishes to say into the Chat Box on the client screen. Everything that can be "said" from this Chat Box can be duplicated in your scripts.
There are several commands that result in your saying something in Iptscrae. They all have the same format:
A string is a group of characters enclosed in double-quotes:
As you will recall from the previous lesson, you may concatenate strings together with the "+" operator:
will result in:
When you are concatenating strings, don't forget to add spaces in between words!
CHATSTR is a unique, named variable in Iptscrae that stores the string of what is said by a user at any given time. Whenever an INCHAT or OUTCHAT event is called, the chat text is assign to CHATSTR. The value stored in this variable can be tested and modified by a script. Note that when you say:
The == checks to see if they are equal. If they are, it returns a one, if not, it returns a zero. The IF command runs your routine if it gets a one, and doesn't if it gets a zero. However, when you say:
The = makes the second expression equal to the first. It assigns the string you specify to the variable CHATSTR. Remember: CHATSTR is the contents of what is being said, and has been detected by either INCHAT or OUTCHAT. Thus, when you change the contents of CHATSTR, you change what you see on the screen. If you use it in an OUTCHAT routine, what you originally said is never seen. If it is used in an INCHAT routine, you see the changed contents on the screen, but the original saying in the log window is not affected.
You've used SAY several times in your lessons, and you know what it does. CHAT is a synonym for it. I have not seen any scripts that use CHAT instead of SAY, although both do the same things.
The string used by SAY may contain special symbols which will cause it to act differently, depending on the symbol:
":<string>" SAY will cause the string to appear in a "thinking" balloon on the screen.
"!<string>" SAY will cause the string to appear in a "shouting" balloon on the screen.
"^<string>" SAY will cause the string to appear in a persistent box that will remain on the screen until the user SAYs something else.
";<string>" SAY will cause the string to appear in everyone's log window…but not on the screen.
In addition to affecting the type of balloon displayed, you can also cause the text to appear at a specific location on the screen by preceding it with "@x,y <string>", where x and y are the horizontal and vertical coordinates of where you want the text to appear. The "@x,y" are INSIDE THE STRING. For example:
Will cause the message "Hello, world!" to appear at the upper left portion of the screen.
"<string>" x y SAYAT
This is another method of saying something at a specific position. In this case, x and y, the horizontal and vertical coordinates, are not part of the string, and can be manipulated without building them into the string. This method is commonly used for "spoofing", making text appear to come from another user, when actually it came from you.
In addition to the CHAT, SAY and SAYAT commands, there are other commands that affect the display of information during a Palace session.
This command sends a private message to another user. It has the same effect as selecting the user for Whisper Mode. In this case, you must have the userID of the person you wish to whisper to. Remember, you can use ROOMUSER, WHOCHAT, WHOME (if you want to whisper to yourself!) or WHOTARGET to get userIDs, depending on the situation.
This command generates a message that everyone in the room sees. It appears in the upper left-hand corner of your screen unless you preceded the words with "@x,y" to control its position.
This message, too, appears in your upper left corner, but only you see it. In cyborgs, it would be used for a routine that detects something and lets you know when it happens, or some routines use it for documentation. (Say the right command, and the routine help appears on the screen.) Just like the ROOMMSG, you can control the position of the message on the screen by preceding the words with "@x,y" at the beginning of the string.
This makes your message appear in YOUR Log Window only. No one else's Log sees this. If you want a message to appear in everyone's log windows- but only in the log- start your message with a semicolon (;) as mentioned above in the information about SAY.
This message appears in every room of the palace for everyone to see. Depending on the server, this may be restricted to use only by Wizards and Gods.
This is short for Super USeR MeSsaGe. It sends the specified message to all Wizards and Gods on the server. In effect, it does the same thing as ~page <message>.
This displays the selected message in the status bar (just above your Chat Box) on your screen. Like LOGMSG, it only appears in your screen, no one else's.
The Truth of the Matter - Boolean Operators
In 1854 George Boole published "An investigation into the Laws of Thought, on Which are founded the Mathematical Theories of Logic and Probabilities". Boole approached logic in a new way reducing it to a simple algebra, incorporating logic into mathematics. He pointed out the analogy between algebraic symbols and those that represent logical forms. It began the algebra of logic called Boolean algebra (meaning two-valued logic) which now finds application in computer construction and programming, switching circuits etc.
Logical operators take two values and perform Boolean logic operations. Typically, programmers use logical operators to evaluate compound expressions. They return a logical value. Logical values are true (non-zero) and false (0, zero). Logical operators are usually used with conditional statements
The following is a list of the logical operators available in Iptscrae:
value value ==
This operator pushes a 1 onto the stack if the two values are equal. Otherwise, it returns a 0. If the two values are strings, the comparison is case-insensitive.
value value != value value <>
This operator pushes a 1 onto the stack if the two values are not equal. Otherwise, it returns a 0.
valueA valueB <
This operator pushes a 1 onto the stack if valueA is LESS THAN valueB. Otherwise, it returns a 0.
valueA valueB >
This operator pushes a 1 onto the stack if valueA is GREATER THAN valueB. Otherwise, it returns a 0.
valueA valueB <=
This operator pushes a 1 onto the stack if valueA is LESS THAN OR EQUAL to valueB. Otherwise, it returns a 0.
valueA valueB >=
This operator pushes a 1 onto the stack if valueA is GREATER THAN OR EQUAL to valueB. Otherwise, it returns a 0.
valueA valueB AND
In this case, if BOTH values are True, (equal to 1 or more) a 1 is placed on the stack. Otherwise, if one of the values is not True, a 0 is pushed onto the stack.
valueA valueB OR
This operator pushes a 1 onto the stack if EITHER of the values is 1 or greater (TRUE), otherwise it returns a 0.
The operator pushes the logical inverse of value on the stack. In other words, if the value is equal to 0, a 1 is pushed onto the stack. If the value is non-zero, a 0 (zero) is returned.
1. Make a routine that is triggered when someone says, "Who came in?" If you're the last person in the room, have an anonymous message appear saying "God sez..." you "came in last". Since it is anonymous, make a note appear in your log that you said it.
2. When someone says, "this is personal", a message that only you see appears on the screen saying "it's for you," followed by your name.
3. When someone says, "page a wizard", do so- make a page that says they told you to do it. NOTE: Use this ONLY for our class. I do NOT recommend leaving this in your cyborg on ANY other basis!
4. When someone says "emergency", have a message appear below the screen saying, "Dial 911!"
5. When someone says "whisper it to me", have a routine automatically whisper the word "it" to them.
6. Go back to your painting routines "diagonal", "laser", and "cupid", and fix it so that no one sees you say those command words.
Whenever you type something into your Chat Box and press your Enter key, you create an event which triggers several handlers. It is possible to trigger the INCHAT and OUTCHAT handlers in your cyborg.ipt, the INCHAT handler in a spot in the room your are currently in and the INCHAT handler of other user's cyborg.ipt file. See if you can write a routine that demonstrates the ORDER in which these things happen.
Using the "^" to precede a string used with say causes a persistent sign to appear over your AV on the screen. HOWEVER, this is not updated when a new person enters the room. In other words, someone who is in the room at the time the string is spoken will see the sign. A new person, coming into the room, will NOT see it. This is something to keep in mind when you are displaying a "BRB" sign! You might want to think of another method of handling this, such as with a prop.
Whenever you are formatting strings to display on the screen, don't forget to consider spelling and grammar. Sentences normally begin with capital letters and end with a punctuation mark. There are spaces in between words.
<Previous> <Iptscrae> <Next>