Advanced Scripting

From Fortress Forever Wiki
Revision as of 16:48, 13 February 2008 by DrSatan-12955 (talk | contribs) (um...idk what I'm doing. trying to update this tut.)
Jump to navigationJump to search

Advanced Scripting

For advanced scripting you will need to have some basic knowledge of scripting to begin. If you are new to scripting you may want to review the basic scripting section first. You may also want to consider getting a better text editing program. However, as with basic scripting, any text editor will suffice.


What makes it advanced?

Advanced Scripting generally consists of nothing more then a series of basic scripts combined into one config file.

However as you begin scripting more you will need to use more complex commands and parameters.


Community Scripts

If we are looking for a specific script and aren't ready to script it on our own, a colaboration of some of the most common scripts used can be found in the Scripts Category of this wiki.

Creating our own

Sometimes we are not going to find what we are looking for in the Scripts Category and we will have to create our own.


This may seem like a big task right now, but this tutorial will walk you through the general process of creating a custom config.

But before we begin, there are 2 things that we absolutely need to do to be able to script:


  1. The first thing we need to do before we think about scripting is figure out what exactly we want to do. Once we are confident we have defined our goal, we can safely move on and begin scripting.
  2. Open your text editing program and keep that on hand.

The Basics

Now because there are so many possiblities for what we can script, covering everything is going to be impossible. But what we can cover are the basics!

New Commands and Parameters

Below you will find a list of the most commonly used parameters and a brief description of each and how it is used.

This list is by no means meant to be a list of the only commands you can use.

Command Parameter Description
Alias Alias <alias name> "command" Alias a command. An example can be found below.
bind bind <key> "command" binds a key to preform a desired action
bindtoggle bindtoggle <key> "command" binds a key to toggle a specific command
wait Stop command parsing until next frame. One wait command is equal to .01 seconds.
+ (plus) + <command / alias> Alone it does nothing. However when used in conjunction with a command / alias, the "+" tells the game to only activate the bind while the specified button is being pressed.
- (minus) - <command / alias> Alone it does nothing. However when used in conjunction with a command / alias, the "-" tells the game to de-activate once the specified button has been released.
; (semicolon) The ; (semicolon) is used in advanced binds / scripts to link serveral commands together into one bind.

Example of an alias

  • Alias - An alias is used in conjunction with a bind. We can think of an alias like making a new command with whatever parameters we want. Remeber we must still call upon the alias within a bind for the game to recognize the alias and preform the desired command. When creating an alias the name can be anything we want, however we need to make sure that we have not already aliased that name in another script / config. The simplest way to do this is to use the find command in the console. Not all situations will require an alias, however if we are making a large script / bind we may want consider using alias' to make things simpler. In the example below we will be aliasing several commands. We will then call on the commands with a bind. Feel free to test the example in game to see it in action!
alias d_1 "bind 1 slot1"
alias d_2 "bind 2 slot2"
alias d_3 "bind 3 slot3"
alias d_4 "bind 4 slot4"
alias d_5 "bind 5 slot5"
alias d_6 "bind 6 slot6"
alias d_7 "bind 7 slot7"
alias d_8 "bind 8 slot8"
alias d_9 "bind 9 slot9"
alias d_0 "bind 0 slot0"
alias default "d_1;d_2;d_3;d_4;d_5;d_6;d_7;d_8
;d_9;d_0"
bind f "default"

File:Note.png NOTE: In this script we have aliased several things: d_2, d_3, d_4, d_5, d_6, d_7, d_8, d_9, d_0, and default. We then use a bind to link them all together.

Keeping it Clean

Configs and get messy really quick, so when your making your scripts try to group things together.

For instance a script that has a lot of aliases and a lot of binds would benefit from headers:

================
      Binds
================


================
     Aliases
================

File:Note.png Note: Little things like this will go a long way in keeping things clean and easy to read.

Combining Commands

Always remember that you can add more then one command / parameter to a single bind.

2 binds like:

bind space "dropitems"

bind f "say_team Flag Toss Attempted!!! {%h}{%a} Flag dropped in %l"

Could be placed into one bind:

bind "SPACE" "dropitems; say_team Flag Toss Attempted!!! {%h}{%a} Flag dropped in %l"