Difference between revisions of "How to make a script"

From Fortress Forever Wiki
Jump to navigationJump to search
(Work in progress!!)
 
Line 97: Line 97:
 
<code><pre>bind g slot1</pre></code>
 
<code><pre>bind g slot1</pre></code>
 
g is our key and slot1 is the command to change to the crowbar.
 
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:
 +
<code><pre>name WhenFFwillout</pre></code>
 +
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:
 +
<code><pre>bind k "say_team I've got the flag!"</pre></code>
 +
This will send that message to all members of your team.
 +
 +
Another usage:
 +
<code><pre>bind KP_ENTER "detpack 15"</pre></code>
 +
This is a bind to the command to place a 15 second [[Buildable:Detpack|detpack]], when playing as the [[Class:Demoman|Demoman]].
  
 
===Creating a simple config file===
 
===Creating a simple config file===

Revision as of 16:40, 13 January 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 page.

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

Default Config Files

config_default.cfg | detail_settings_default.cfg | detail_settings_max

Class Specific Config Files

demoman.cfg | engineer.cfg | hwguy.cfg | medic.cfg | pyro.cfg | scout.cfg | sniper.cfg | soldier.cfg | spy.cfg

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?

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, there 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 create 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. For this, we will use the example above. In this example we are using a simple bind that would be used by all classes. To execute this we will need to create a new config file (LINK)?


Once we have decided what bind we want and created it, we need to place this bind into a config file to ensure that the bind is executed while in game. Start by navigating to the appropiate config file. The next step is to determine whether or not our simple bind will be used by all classes or by a single class. For this, we will use the example (LINK) above. In this example we are using a simple bind that would be used by all classes. To execute this we will need to create a new config file (LINK)?