Getting Started

From COD Modding & Mapping Wiki
Revision as of 02:07, 16 October 2008 by Zeroy (talk | contribs) (New page: == Getting Started == This section will include serveral things you need to know before you start scripting. Image:Nutshell.png All scripts are contained within simple text files...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Getting Started

This section will include serveral things you need to know before you start scripting.

All scripts are contained within simple text files that contain no formatting, so programs such as Word are not to be used. The file format used for scripts within the Call of Duty series is 'GSC' (.gsc). It is recommended you use a simple but effective editor for programming, such programs include Crimson Editor, Programmers Notepad and Editplus.

A few things you need to know before reading any further are a few common words used within scripting.

Variables: variables are data storage locations which are assigned a name. For example...

intVar = 1;
floatVar = 0.5;
strVar = "Text";
boolVar = true;

The variables are declared on the left, and assigned a piece of data such as an integer (whole number), float (a number containing a decimal), string (text) or a boolean (true/false).

Entity: this is something that is used in maps which can be called in the script. Entities include players, guns, objectives, script_models, etc.

They can be called using their relative targetname or classname which is defined in the map.

Functions: an action or procedure that can be called or threaded and can return a value. For example...

funcMove()
{
  self moveY(320, 3);
}

The function in the above code is called "funcMove", when called, it will perform the actions inside the brackets.

Arguement: these are required pieces of data that needs to be sent when requested from functions.

For example, if a function is shown as

function(arg1, arg2)

The function is asking for two arguements to be sent to the function. An example of this in use...

{
ent function(320, 5);
}
function(dis, time)
{
ent moveZ(dis, time);
}

As you can see, 'dis' is called and is given the value of 320, this can then be used as a variable called 'dis', ditto for time.

Calling/Threading: these are used with functions. A function can be called or they can be threaded.

If a function is threaded, then the function is performed while the script continues, whereas if a function is called, the script will wait until the function is completed before it continues. Examples...

function(); // This is how to call a function
thread function(); // This is how to thread a function[/code]


Self: this is used inside functions when a function is called on an entity. Self is used instead of an entity.

For example... (You will see in this example that in the function, called function(), self is equal to 'ent' which was decalred in a different function)

{
 ent = getent("ent","targetname");
 ent function();
}
function()
{
 self moveZ(150, 5);
}