Introduction
Comments in Iptscrae
Clean & Compact scripting
ON INCHAT, OUTCHAT, ENTER
Ways to spit out messages
Private Messages
Wild Cards
Iptscrae Math
Using Variables
IF Statements


Iptscrae Basic's


This tutorial is also going to be geared to writing scripts for your cyborg.ipt (and no there isn't really a huge difference between the scripting for your cyborg and your palace, but there IS a difference).

OK... wow, where do we start :)

First thing we should talk about is the layout of your scripting. I, most would say, am a sloppy scripter/programmer. Scripts should be clean, they should be easy to read, so that later, when you want to edit the script, you can see what the heck you we re doing with it in the first place. Another important feature to clean scripting is adding comments to your script. In Iptscrae a comment is assigned with the ";" . The ";" tells the computer not to execute the following line (or whatever is after the ; until it a new line starts), because it is just there for the scripter's purposes.

Here's an example of a comment.

ON OUTCHAT {
   {  "hi" SAY ;you can add a comment here
      ;or you can add a comment here... Don't worry about the
      ;rest of the script... just look at the comments.  
   } CHATSTR "sayhi" == IF
 }


Now, as far as spaces and case sensitivity goes, Iptscrae most a lot of languages is not too picky. You can put as many spaces from command to command as you want, just as long as there is at least one. For example:

ON OUTCHAT {
   { "hi"             SAY ;remember this script?
   }CHATSTR "sayhi"             ==   IF  
}

Notice how in some areas I added a bunch of spaces to this script, but in with the }CHATSTR, I took away a space. It really doesn't matter, but once again it brings up the topic of sloppy scripting. You want your scripts to look compact, but clean. You don't want to waste lines with tons of spaces, but you don't want your whole script to be one line either. Got that? Good :)

As far as case sensitivity (which, for those who don't know, means that there would be a difference between capital and lower-case letters) there is none. "ON OUTCHAT" is the same as "on outchat", but I like to keep my important function of the script in capitals, just so that when I come back to edit, I know where to begin looking.


OK, y'all ready to begin scripting?

Your Cyborg.ipt has three different sections: ON INCHAT, ON OUTCHAT, ON ENTER. Now this is how an empty ON INCHAT, ON OUTCHAT or ON ENTER would look like:

 
        ON ENTER {
        
       }

The "{" is stating that it is the beginning of the scripting area and the } specifies the end. These brackets also have the same meaning in the scripts, the beginning and the end. You will see what I mean by this in a second.

A script put into your ON INCHAT will execute when someone else types a key word. For example, this script will execute when someone else says the word "beer".

ON INCHAT {
  { 
    "mmm.  Did someone say beer?" SAY
   } CHATSTR "beer" == IF
 }
So as you can see, we have the beginning and end brackets for the INCHAT section, and WE ALSO HAVE the beginning and end brackets for the script... Where you have a beginning, you need and end. The first bracket states that the INCHAT section has begun. The second bracket states that a script within the INCHAT section has begun. The third bracket states that the first script inside the INCHAT section has ended and the fourth and final bracket specifies the end of the INCHAT section. Got that? Hope so :

Now we will discuss the jumbled information inside those brackets. Take the line

"mmm. Did someone say beer?" SAY

This is simply stating that you should SAY the words "mmm did someone say beer?" This would be just like you typing in those words by yourself. The line:
} CHATSTR "beer" == IF

is stating that you should say 'mmm. Did someone say beer?" when someone else types the word 'beer' (someone else because it is in your INCHAT section).
CHATSTR stands for CHAT STRING. A CHATSTR is basically a word or a series of words. That line is saying... 'computer, IF ( which is specified by the == IF ) you hear the word 'beer' , I want you to say 'mmm. Did someone say beer'.

WHEW, we're getting there!

OK, so now that you know what happens to that beer script in the ON INCHAT section, can you guess how it would work in the ON OUTCHAT section? If you took that same script and put it into your OUTCHAT section, it would work if YOU said the word beer ( in stead of someone else, like the INCHAT section ). Easy enough, right?

The ON ENTER section is not too important, we will discuss it briefly later.



Now that you know what SAY does, let's discuss some other options for talking or sending messages out.

Here is a quick list:

SAYSpits out a message which will come from your mouth
ROOMMSG Spits out a message in the top left hand corner of the screen. It will look like the message came from the server. It will not show your name with the message on the log.
PRIVATEMSG Just like clicking on someone and sending them a private message... Can be tricky, read below.
LOCALMSG Spits out a message that only you will see on your computer.

These are all used exactly like SAY except for PRIVATEMSG. So, let's take our ON INCHAT section, and add a new script to it with a ROOMMSG in it.

    
ON INCHAT {
  { 
    "mmm.  Did someone say beer?" SAY
   } CHATSTR "beer" == IF 
 
  {
   "so, this is the new script, huh?" ROOMMSG
   } CHATSTR "new" == IF
 }

As I'm sure you can see, this script will spit out the message 'so, this is the new script, huh?' at the top left of the screen when someone else types the word 'new'. Also notice where the second script fits in, look at how the brackets are place d.

Now for a PRIVATEMSG explanation. Using PRIVATEMSG is like clicking on someone and sending them a message. By clicking on them, you are specifying who you want to send that message to. So when you are writing a script for a PRIVATEMSG, you must also fi nd a way to specify who the private message will go to. To do this you need the script to first find the specific user's ID. Right now the only to do this is with WHOCHAT... WHOCHAT provides the user ID of someone who just said the key word (don't worr y, you'll understand what the heck I'm talking about in a minute).

ON INCHAT {
  { 
    "Hey, Are you talking about beer?" WHOCHAT PRIVATEMSG
        
  } CHATSTR "beer" == IF 
 }

Now, let's get a bit deeper.

Let's take the WHOCHAT function to a new level. Let's say that you want to write a script in your ON INCHAT section that will spit out a special hello to someone specific who says hi to you.

Here's what the script will look like:

{ 
"wazup Joe!" SAY 
   } WHOCHAT WHONAME
 "Joe" == CHATSTR "hi adam" == AND IF
OK.. Let's tear this one apart! First line you should know. It is specifying to SAY the message "wazup, Joe!". The WHOCHAT is providing the user ID of the person who just said hi to you. What the WHONAME is doing is converting the ID to the name. Now if that name matches the name between the next quotation marks ( "Joe" for example ), and if that person DID say "hi adam" - the message "wazup Joe!" will be spit out to only the user, Joe. Comprende?

Now because you just specified the CHATSTR to be exactly "hi adam" this script will ONLY work when Joe ( or whomever you specified ) says those exact words-- "hi adam". We all know that sometimes we say "hello adam" or "hey adam" or even "hola adam". < p> Most Programming languages have a "wild card". In UNIX the wild card is "*". For example if you have a bunch of files in a UNIX directory and ten of them look like so: adam1.html, adam2.html, adam3.html and so on... And let's say that you wanted to rem ove all of those "adam" files. Instead of removing each one, one by one, you can use the wild card to remove them all at once. Example: rm adam*

In Iptscrae the wild card is ".*". So let's take that hi script again and put it in so that it will spit out your message when anyone says anything with a h adam (hi adam, hey adam, hola adam, hi there adam).

{ 
"wazup Joe!" SAY 
   } WHOCHAT WHONAME
 "Joe" == CHATSTR "h.*adam" GREPSTR AND IF
Two things: First you'll see what I mean by the wild card, next is the 'GREPSTR AND IF' which has replaced the '== IF' . Simple explanation: Instead of '== IF' use GREPSTR IF anytime you use a wildcard. The AND IF is just stating that you want the sc ript to execute if the user's name is, Joe, AND IF Joe says "h.* adam" (hi adam, hola adam, etc). Take another deep breath!


Now, let's take a look at different mathematical statements in Iptscrae. We'll stick to the simple functions: addition, subtraction, multiplication, Division.

Like everything in Iptscrae, these functions are somewhat backwards, but relatively easy once you get used to the twisted way to script them :)

In our normal everyday work an addition would look like this:

8 + 8 = 16

In our twisted world of Iptscrae, the same addition would look like this:

8 8 + 16 =

The same goes for division, subtraction and multiplication.

8 8 - 0 = , 8 8 * 64 = , 8 8 / 1 =

Not too bad, huh? Just notice that in Iptscrae, numbers are not put in quotations like words are. If you tried to do this:

"8" "8" + it would add up to "88". Just like if you tried this:

"hi" "there" + it would add up to "hithere".


Variables are used in all programming/scripting languages to store information. A variable is something that you define within a script like so:

ON OUTCHAT {
5 variablea =
"Adam" variableb =
}

Now, what I did here was create two variables: variablea and variableb. I assigned the number, 5 to variablea and I assigned the string or word to variableb. Now throughout the rest of the script I can use these variables. Take a look at this:

ON OUTCHAT {
5 variablea =
"Adam" variableb =

{ variablea variablea + variablec = }

}
What I did was add the contents of variablea plus the contents of variablea again, then I made a new variable which would store the result of the addition. So, variablec would then contain the number, 10. Here's how we can spit out the contents of the v ariables.

ON OUTCHAT { 
5 variablea = ;assigns 5 to variablea
"Adam" variableb =  ;assigns "adam" to variableb

{ variablea variablea + variablec = 
  "The contents of variablec are: " variablec ITOA + SAY
} CHATSTR "addemup" == IF

};ends the outchat section

You can see how I made the script spit out the contents of variablec. What I had to do was take variablec, then use ITOA which stands for, Integer To Atom. All this does is convert a number to a word. As for the + say, I had to add that in because I wa sn't just saying one thing, I was saying "The contents of variablec are:" AND I was saying, what was in variablec. Therefore I needed the +. I know that isn't a great explanation, but it's the best I can do, I don't really know the techy side of it.

ON INCHAT { ;starts the INCHAT section
0 apples =  ;makes the variable "apples" and assigns 0 to it.

 { "you have " apples + LOCALMSG ;says how many apples you have
 } CHATSTR "howmany" == IF

} ;end inchat

OK, let's say that you have this simple script, that tells you how many apples you have. Right now, you only have 0 apples and there is no way for the script to add any more apples to what you have. Also, if you look closely at that script, 0 apples = is right in the inchat section... this means that everytime you say anything apples is going to equal 0. For our next script, we are going to put 0 apples = in a conditional statement, which means apples will only equal 0 when a certain condition applies (such as saying something like: set, which means set apples to 0.

So let's add in a way to get more apples. And then after that, we'll add a way to take away apples too.


ON INCHAT { ;starts the inchat section
apples GLOBAL
{
0 apples =  ;makes the variable "apples" and assigns 0 to it.
} CHATSTR "set" == IF
 { 
"you have " apples ITOA + LOCALMSG     ;says how many apples you have
} CHATSTR "howmany" == IF
  { apples 1 + apples = ;        takes apples, adds 1, makes it equal to apples.
 } CHATSTR "addone" == IF
 { apples 1 - apples = ;takes apples, subtracts 1, makes it equal to apples.
 } CHATSTR "takeone" == IF 
} ;end inchat 

Cool, that's not too hard, is it? All I did was write a sub-script that would allow me to add an apple to what I have, and subtract an apple from what I have. Done? Nope. Now, I want to add a sub-script that will tell me when I have 5 apples. Yes, I started with 0, but then if I say "addone" 5 times, I'll have five... then I want a special message to pop up telling me I hit my goal of five apples... so let's do this:

ON INCHAT { ;starts the inchat section
apples GLOBAL
 {
  0 apples =  ;makes the variable "apples" and assigns 0 to it.
 } CHATSTR "set " == IF
 { "you have " apples + LOCALMSG ;says how many apples you have
 } CHATSTR "howmany" == IF
 
 { apples 1 + apples = ;takes apples, adds 1, makes it equal to apples.
 } CHATSTR "addone" == IF

 { apples 1 - apples = ;takes apples, subtracts 1, makes it equal to apples.
 } CHATSTR "takeone" == IF 


 { "YOU NOW HAVE FIVE APPLES!" LOCALMSG } 5 apples == IF


} ;end inchat

See, that's an if statement. It will automatically say "you now have five apples!" right when my apples variable hits five. I could also do something like this:

ON INCHAT { ;starts the inchat section
{
0 apples =  ;makes the variable "apples" and assigns 0 to it 
"false" goal = ;sets my "goal" variable to false.
} chatstr "set" == IF ;now we'll set the variables goal and apples... 

 { "you have " apples ITOA + LOCALMSG ;says how many apples you have
 } CHATSTR "howmany" == IF
 
 { apples 1 + apples = ;takes apples, adds 1, makes it equal to apples.
 } CHATSTR "addone" == IF

 { apples 1 - apples = ;takes apples, subtracts 1, makes it equal to apples.
 } CHATSTR "takeone" == IF 
 
 { "true" goal = } 5 apples == IF
 { "Great, you got your 5 apples!" LOCALMSG } "true" goal == If

} ;end inchat

Now, what I did there may get tricky to understand, but it is a very very important feature of scripting. If you have never scripted or programmed before, you need to allow your mind to work on a whole new level. You must create variables and set them to certain status', then when something else happens it can change the status of that first variable, which in turn may change the status of another variable... It can be tricky at first, and it is very hard to explain other than by example, so if you don't understand, just keep looking over the last three sections until you get it... Or if you still have a question, try our Knowledge Base.