Jump to content

JeffR

DEVGRU
  • Content Count

    1004
  • Joined

  • Last visited

Everything posted by JeffR

  1. JeffR

    Objects

    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

    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 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

    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

    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

    Github

    stub
  8. JeffR

    Linux

    stub
  9. JeffR

    MacOS

    stub
  10. JeffR

    Windows

    stub
  11. JeffR

    Editing

    stub
  12. JeffR

    Controls

    stub
  13. JeffR

    Canvas

    stub
  14. JeffR

    Basic Syntax

    Basic Syntax Like other languages, TorqueScript has certain syntactical rules you need to follow. The language is very forgiving, easy to debug, and is not as strict as a low level language like C++. Observe the following line in a script: // Create test variable with a temporary variable %testVariable = 3; The three most simple rules obeyed in the above code are: Ending a line with a semi-colon ; Proper use of white space. Commenting. The engine will parse code l
  15. What is TorqueScript? TorqueScript (TS) is a proprietary scripting language developed specifically for Torque technology. The language itself is derived from the scripting used for Tribes 2, which was the base tech Torque evolved from. Scripts are written and stored in .cs files, which are compiled and executed by a binary compiled via the C++ engine (.exe for Windows or .app OS X). The CS extension stands for “C Script,” meaning the language resembles C programming. Though there is a connection, TorqueScript is a much higher level language and is easier to learn tha
  16. JeffR

    API Reference

    Generated API Documentation
  17. JeffR

    API Reference

    Generated API Documentation
×
×
  • Create New...