Newbie Guide to Tribes Coding Volume 1
Welcome to the huge world of Tribes Coding. This guide will help you learn how to be a master. In this first volume, I will teach you the basics. If you already know the basics of Tribes code, then skip to the next volume.
Required files
I suggest getting pakscape from
http://www.geocities.com/cocabearYou need a compresser and a decompresser to vol and devol the files
Brief History
Tribes code is more or less a twisted version of the C++ language. It carries all of the same traits, but it is easier to work with.
The Basics
If you have already looked at some of the code you may notice that it looks a little like algebra. Some things can be figured out like algebra, however, you MUST not think of it as algebra. You must also remember to use the {} brackets in functions and to end every line except a statement line with a ; at the end
In the code, there are 2 main things that almost run it all. They are called Global Variables and Local Variables.
Global Variables
Global variables can be placed anywhere outside a function and in any file. They start with the $ sign and usually have important information after it. Ex. ($Color = Red;).The whole point of a Global Variable is that it holds important data that can be accessed at any time. Now you may be asking this. Why worry about Local Variables if these Global Variables can do so much? Lets go find out.
Local Variables
Local Variables can only be places inside functions, and are probly the most important part to the code. They start with a % and are usually before any of the Script (long stuff that you won’t understand yet). Here is an example (%Color = Red;). As you may notice, The difference between a Local Variable and Global Variable seem to be only a $ and a $. One is inside a function and one is not. Local Variables are essential because is puts everything at ease to read and understand right next to each other. If you wanted to find a Global Variable, you would have to search all over the place. Global Variables can never be repeater, but Local Variables can be used as many times as you want as long as they are not repeated in the same function.
Function
I have talked about function here and function there, but I haven’t really explained what a function is. All a function is, is a block of code that commands the game to do something when it is called from somewhere else. Still with me? Lets use a little example to show what I am talking about
function LocalSay()
{
Say::Local(“sayHello�);
}
When that function is called your play will say hi in a local area, meaning it won’t show up in box, but it will still play a sound near you. Let me break this down to make it easier. the first word function which must ALWAYS be in lowercase tells Tribes that you want to do something. The words next to it “LocalSay� Can pretty much be what you want them to as long as they are not spaced. Those are called the Function Names. With that in consideration, you should name them according to what you are putting inside. The () at the end is usually filled variables in some cases. In this case, you don’t need any variables inside, so we just leave it blank. Notice how this line doesn’t have a ; at the end? This is a statement line. I will talk more about this later. On the next line you have a { bracket. Anything between the { and } brackets will be included in the function. You must have them as they start and end the function block. The next line Say::Local(“sayHello�); is the actual code. The word Say is telling Tribes that you are going to say something. The :: Means that the next word will be tied on to the first which is Say. The word Local is telling tribes that what you say will be in local range. Then Inside the () is the sound name of what you are going to say. Notice this has a ; at the end. This is because it is a code line, and all code lines must have a ; at the end. Ntice that if you type Say:Local(“sayHello�); Inside the Tribes console, it will do the EXACT SAME THING.
If, Else If. Else
They mean exactly what they say. You want to make a function to do something.. But you want it to “think� on it’s own. So if this were to happen, then do this. else if this were to happen, then do this. Or else do this. They are set up almost the same way as functions are, and do not really need a lot of explaining. If you look throught the code you should be able to understand well enough what I’m talking about.
The More Advanced Function
$T::TauntNum = 2;
$T::Taunt[1] = "tauntDance";
$T::Taunt[2] = "tauntMissedMe";
function Taunt(%msg)
{
if(%msg == "")
{
%msg = floor(getRandom() * $T::TauntNum);
Say::Local($T::Taunt[%msg]);
}
}
You may be thinking.. What the hell is that? If you have been paying attention, you should be able to figure out most of it by yourself. The top 2 lines are Global Variables. Remember, they show important information that will be used later. You should be able to figure out what those 3 Global Variables mean.
Then you have your function. The name of this function is Taunt as it’s purpose is to play local taunts when it is called. Notice the %msg between the () brackets. That is a Local Variable that will be used for a certain thing. The next thing is the { bracket which opens the function block. The next thing is an if statement. This is saying If %msg is equal to nothing, then do this. if has brackets of it’s own as it is another form of a function. Now back to where we were. If %msg is equal to nothing then %msg is equal to (what the hell is that?) floor means a base number. The brackets state what the base number is. In Tribes, there is a function called getRandom somewhere. The fuction’s purpose is to get a random number. next is the * sign. This has to do with the getRandom function. it is used as a multiplication sign and is saying to multiply the next “number� by 1. What it is asking to multiply by one is… (Hey It is the Global Variable!). It is asking to pick a random number of the $T::Taunt variables. It calls $T::TauntNum as it says the amount of numbers that will be used.
What we have here is a random number of these 2 variables. So it is a 50/50 chance that either one of these will be picked.
The next line of code says what we have made in the previous function.. It asks Tribes to Say in a Local area the random message.
Well that is enough of that for now..
FAQ
Well I need some FAQ to have one, so give me your FAQ so I can answer them and write them in here!