Jump to content


  • Content Count

  • Joined

  • Last visited


Personal Information

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. JeffR


    Objects The most complex aspect of TorqueScript involves dealing with game objects. Much of your object creation will be performed in the World Editor, but you should still know how to manipulate objects at a script level. One thing to remember is that everything in TorqueScript is an object: players, vehicles, items, etc. Every object added in the level is saved to a mission file, which is written entirely in TorqueScript. This also means every game object is accessible from script. Syntax Even though objects are originally create
  2. JeffR


    Functions Much of your TorqueScript experience will come down to calling existing Console Functions and writing your own. Functions are a blocks of code that only execute when you call them by name. Basic functions in TorqueScript are defined as follows: // function - Is a keyword telling TorqueScript we are defining a new function. // function_name - Is the name of the function we are creating. // ... - Is any number of additional arguments. // statements - Your custom logic executed when function is called // return val - The value the function will give bac
  3. Control Structures TorqueScript provides basic branching structures that will be familiar to programmers that have used other languages. If you are completely new to programming, you use branching structures to control your game’s flow and logic. This section builds on everything you have learned about TorqueScript so far. if, else This type of structure is used to test a condition, then perform certain actions if the condition passes or fails. You do not always have to use the full structure, but the following syntax shows the extent of the con
  4. JeffR


    Operators Operators in TorqueScript behave very similarly to operators in real world math and other programming languages. You should recognize quite a few of these from math classes you took in school, but with small syntactical changes. The rest of this section will explain the syntax and show a brief example, but we will cover these in depth in later guides. Arithmetic Operators These are your basic math ops. Operator Name Example Explanation
  5. JeffR


    Types TorqueScript implicitly supports several variable data-types: numbers, strings, booleans, arrays and vectors. If you wish to test the various data types, you can use the echo(...) command. For example: %meaningOfLife = 42; echo(%meaningOfLife); $name = "Heather"; echo($name); The echo will post the results in the console, which can be accessed by pressing the tilde key ~ while in game. Numbers TorqueScript handles standard numeric types: 123 (Integer
  6. JeffR


    Variables A variable is a letter, word, or phrase linked to a value stored in your game’s memory and used during operations. Creating a variable is a one line process. The following code creates a variable by naming it and assigning a value: %localVariable = 3; You can assign any type value to the variable you want. This is referred to as a language being type-insensitive. TorqueScript does not care (insensitive) what you put in a variable, even after you have created it. The following code is completely valid:
  7. JeffR


  8. JeffR


  9. JeffR


  • Create New...