Difference between revisions of "How to make a script"

From Fortress Forever Wiki
Jump to navigationJump to search
(removing advance scripting to implant on a NEW page.)
(help added)
Line 157: Line 157:
  
 
Finally we will need to test our new bind. This can only be done in-game, so we will need to get into FortressForever. Once we are in the game (and have joined a server) we can test out our new bind by pressing the desired key. Again using the [[#Example of a simple bind|example]] above, if we press '''"g"''' our character should change weapons to our [[Reference:Weapons#Melee_Weapon_Reference|melee weapon.]]
 
Finally we will need to test our new bind. This can only be done in-game, so we will need to get into FortressForever. Once we are in the game (and have joined a server) we can test out our new bind by pressing the desired key. Again using the [[#Example of a simple bind|example]] above, if we press '''"g"''' our character should change weapons to our [[Reference:Weapons#Melee_Weapon_Reference|melee weapon.]]
 +
 +
==Help==
 +
Altough we have tried our hardest to be as detailed and helpful as possible, we all know that there is no way we can possibly answer all your questions. So if you feel your in need of some major help, please feel free to contact someon via the portals below:
 +
 +
 +
'''IRC'''
 +
 +
 +
 +
'''Email'''
 +
 +
If you can not find what your looking for please feel free to email us at <tt>FortressForeverHelp@gmail.com</tt> and we will assist you the best we can.
 +
 +
 +
Please use descriptive titles in the "subject" line as to assure that your email is sent to the right box and checked by the appropriate person(s).
 +
  
 
==See Also==
 
==See Also==
  
 
For more advanced scripting please visit the [[Advanced Scripting|Advanced Scripting Tutorial.]]
 
For more advanced scripting please visit the [[Advanced Scripting|Advanced Scripting Tutorial.]]

Revision as of 15:23, 13 February 2008


Overview

What is a bind?

A bind in Fortress Forever is a command, or sting or commands, which when executed perform a desired action.

What is a config?

A config in Fortress Forever is a file that contains a series of binds. When the config is executed, it consults the binds to see what parameters are in effect.

Where are binds stored?

Binds are stored in your default config files.

The game stores all of your config files in the following file:
\Steam\steamapps\SourceMods\FortressForever\cfg

You can view a copy of the default config files by looking at the Default Configs Section of this wiki.

By default the game contains 12 config files. These are generally catagorized into two groups.

Default Config Files

Class Specific Config File

The class specific config files are executed every time you respawn. You will want to keep that in mind when considering what to put in your class specific configs.

Syntax

For any key binding or alias binding script within the Source engine developer console, the following format must be followed:

COMMAND <argument1> <argument2>

Quotation marks are NOT necessary for binds or aliases with singular arguments, such as bind 1 slot1.

Getting Started

What programs do I need?

You can use any text editing program to create a bind. However depending on he difficulty of the bind you are going to be creating you may want to look at getting an external program.

Simple binds:

When writing a simple bind there are no specific programs that are needed. It is suggested that you use notepad but your favorite text editing program will work.

Advanced binds:

For more advanced scripting it is suggested that you use either notepad or notepad++.

Key configurations

When writing binds, it is important that you use the correct key configurations. For example if we want to have the melee weapon of a class be activated by pressing the control key. We would have to write a bind that looks like this:

bind CTRL slot1

In this senario we have to use “CTRL” to define the control key.

For a complete list of each key and how it is defined see the script reference page.

Are there any commands I cannot use?

Yes, although you have a lot of access to commands. It would be unfair and potentially dangerous for the developers to allow access to every command in the game. For more information on this please visit the commands and cvars section.

Basic Scripting

Writing a simple bind

A simple bind takes the form of:

bind <key> <command>

For example if we wanted to have the melee weapon of a class be activated by pressing the 1 key, then we could write a bind that looks like this:

bind 1 slot1

“slot1” is the command to activate the melee weapon by default

Each bind you write must be written on a separate line. For example if we wanted to have the melee weapon of a class be acticated by pressing the 1 key and have the secondary weapon of a class be active by pressing the 2 key. We could write a bind that looks like this:

bind 1 slot1
bind 2 slot2

“slot1” is the command to activate the melee weapon and “slot2” is the command to active the secondary weapon by default

Once we have created a simple bind we will need to place it in a config file. This will ensure that the bind is executed while in game.

Example of a simple bind

An example of simple binds can be found here.

Idea: I want to be able to press the "g" key to change to my crowbar as a scout.

Solution using a simple bind: In this example we would want to use a bind to change our weapon to the crowbar.

bind g slot1

g is our key and slot1 is the command to change to the crowbar.

Binds that have parameters

Some commands take arguments when used in the console. For example:

name WhenFFwillout

This command changes your name to the default moniker of Fortress Forever.

If you wish to bind a command that takes a parameter, you must use quotes around the command and argument part of the bind. For example:

bind k "say_team I've got the flag!"

This will send that message to all members of your team.

Another usage:

bind KP_ENTER "detpack 15"

This is a bind to the command to place a 15 second detpack, when playing as the Demoman.

Creating a simple config file

To create a simple config file we will first need to write a simple bind. The next step is to determine whether or not our simple bind will be used by all classes or by a single class. And finally we need to place this bind into a config file to ensure that the bind is executed while in game.


For this, we will use the example above. In this example we are using a simple bind that would be used by all classes. Binds that are used by all classes should be placed into our userconfig.cfg file.


So we have a simple bind, and we know that it is going to be used by all classes. The next stop is to place this bind into a config file.


To do this we must first open our config file. We can do this by navigating our way to the appropiate config file. Again in this example we will be using our userconfig.cfg which is located at the following destination:

steam/steamapps/FortressForever/cfg/userconfig.cfg

For an example of what a default userconfig.cfg looks like see the default configs section of this wiki.


Once we have our config file open we need to place our bind into the file. This is just a matter of copying and pasting the text into the file. Using our example from above our new userconfig.cfg should look like this:

echo User Config Loaded

//Place binds that will be used by all classes here
bind g slot1

We can place as many binds in our configs as we want, just remeber not to attempt to bind 2 keys to the same thing.


Once we have placed the desired binds into our config we will need to save the document. This can be done by either clicking save or going to file/save.


Finally we will need to test our new bind. This can only be done in-game, so we will need to get into FortressForever. Once we are in the game (and have joined a server) we can test out our new bind by pressing the desired key. Again using the example above, if we press "g" our character should change weapons to our melee weapon.

Help

Altough we have tried our hardest to be as detailed and helpful as possible, we all know that there is no way we can possibly answer all your questions. So if you feel your in need of some major help, please feel free to contact someon via the portals below:


IRC


Email

If you can not find what your looking for please feel free to email us at FortressForeverHelp@gmail.com and we will assist you the best we can.


Please use descriptive titles in the "subject" line as to assure that your email is sent to the right box and checked by the appropriate person(s).


See Also

For more advanced scripting please visit the Advanced Scripting Tutorial.