TorqueScript Reference
Typedefs
Construction Operators

Typedefs

typedef type new
 

Detailed Description

Typedef Documentation

◆ new

typedef type new

create a new object

Format
%myID = new class([name])
{
[field = value;]
...
};
Where
  • myID is the return ID that can be used to access the object in the form %myID.myFunction.
  • new is the keyword telling the engine to create an instance of the following class.
  • class is any class declared in the engine or in script that has been derived from SimObject.
  • name (optional) is the object's name for referencing in the form name.myFunction (without % or $ before it).
  • field - You may initialize static or dynamic class fields here, one at a time.
Example
// An SceneObject named 'Truck'
// with two static fields and one dynamic field to define
new SceneObject(Truck)
{
position = "0 0";
size = "5 5";
myField = 100;
};
// A nameless object (tracked by a variable), with no fields to set
%myObject = new SimSet();
Definition SceneObject_ScriptBinding.h:36
Definition simSet_ScriptBinding.h:192