Fork me on GitHub

SourceScript

Easier Scripting for TF2 & Other Valve Games

SourceScript is a small and simple programming language that aims to simplifiy programming configurations for Valve's games based on the Source Engine.

It introduces boolean variables, conditional statements, enumerations, functions and a more readable syntax for commands and best of all: It's fully backwards-compatible with your old scripts!

If you find some bugs or have questions, just leave a ticket on Github.

Try it yourself in the editor! Oh, it's open source too!

Features

Simpler Syntax

SourceScript introduces a simpler syntax to declare aliases and binds. You don't have to write all commands in one line anymore, instead just group the commands in braces. It also generates helper aliases for you when using multiple commands in a nested alias or in a bind.

alias "combo" {
  +attack
  +forward
}

bind "MOUSE4" {
  combo
  say_team "using combo!"
}
alias combo "+attack; +forward"
alias +_bind_0 "combo; say_team "using combo!""
bind MOUSE4 +_bind_0

Enumerations

Enumerations allow you to easily create aliases that enumerate through blocks of commands. This especially comes in handy if you're writing a lot of code.

See this example: This creates a new alias called next that loops through all 3 slots. After slot3, it begins with slot1 or next_0 again.

enum next {
  {
    slot1
  },{
    slot2
  },{
    slot3
  }
}
alias next next_0
alias next_0 "slot1; alias next next_1"
alias next_1 "slot2; alias next next_2"
alias next_2 "slot3; alias next next_0"

Variables and Conditional Statements

Variables allow you to store yes (true) / no (false) values in aliases. They can be used in Conditional Statements to check their value.

isCompetitive = true
if isCompetitive {
  aimbotOff
} else {
  aimbotOn
}

# or use negations
if !isCompetitive {
  aimbotOn
}
alias var_0_isCompetitive TrueHook
alias TrueHook aimbotOff
alias FalseHook aimbotOn
var_0_isCompetitive

// or use negations
alias TrueHook ""
alias FalseHook aimbotOn
var_0_isCompetitive

Variable Scope

SourceScript has variable block scope. This means that if you define a variable within a block, say in an if-clause, it will be only accessible in there.

Also, if you are using multiple files in your project, like in the editor below, variables are only accessible within the current file. If you want to create a variable that you can access in every file, add a dollar sign ($) before the variable name, for example like this: $isCompetitive.

Functions

Now functions are here for you guys who want to create large libraries: Functions will only be included in your code if you use them.

That means you could create a large library of tens of functions and use only some of them without bloating the output with unused functions.

function +Pyro::Panic() {
  cl_yawspeed 3000
  +left
  +attack
}

function -Pyro::Panic() {
   -attack
   -left
   cl_yawspeed 210
}

bind "MOUSE4" {
  +Pyro::Panic()
}
alias +func_Pyro__Panic "cl_yawspeed 3000; +left; +attack"
alias -func_Pyro__Panic "-attack; -left; cl_yawspeed 210"
alias +_bind_0 +func_Pyro__Panic
bind MOUSE4 +_bind_0

As you can see in the example, when using functions in binds functions beginning with a + are automatically replaced so that the - function is also called, just like you were using aliases.

Includes

To use functions from other files of your project, it is needed to include them. This is done with the include statement. For example, use include mylib.ss to allow usage of the functions of mylib.ss in the current file.

Try it yourself!

I started with a basic config framework for TF2 for you <3

Changelog

28th January, 2013

Here's the complete list of changes on Github.

14th December, 2012

Initial release