SimObject-Classes

class ConsoleObject

class ConsoleObject

Is only a parent class from which other classes inherit.

getFieldList()

Get all Fields of the ConsoleObject.

Example:

-- In Map Hirochi Highway, if you do this:
local object = scenetree.findObject(5769)

local flist = object:getFieldList()
for i, elem in pairs(flist) do
    for i1, elem1 in pairs(elem) do
        if type(elem1) == "table" then
            for i2, elem2 in pairs(elem1) do
                print(i..","..i1..","..i2..","..elem2)
            end
        else
             print(i..","..i1..","..elem1)
        end
    end
end

Output See here: Click

class SimObject

class SimObject : ConsoleObject

To get the ID of an object, go into the game, press F11 to open the editor and click on an object of your choice.

void delete_()

Unregister, mark as deleted and free the object.

Example

local object = scenetree.findObject(5769)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
object:delete()
string getField(string slotName, string array)

Gets the field of a Slot of the SimObject

Parameters:

  • string slotName: The name of the member. A list you can see here
  • string array:

Example:

local object = scenetree.findObject(5326)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
print(object:getField("position", "")) -- prints f.e. 27.1023006 -346.459991 36.1747017
setField(string slotName, string array, string value)
  • string slotName`: The Name of the member
  • string array:
  • string value: The new value of the member

Example:

local object = scenetree.findObject(6978)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.

print(object:setField("position", "", "68 -382 40")) -- Sets a n object to Position 68 -382 40
bool isSubClassOf(string className)

Parameters:

  • string className: The name of the class that is checked
Returns:true if className is a sub class of the current object

Example

local object = scenetree.findObject(5989)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
print(tostring(object:isSubClassOf("SceneObject"))) -- prints true, because the ID is member of the Class SceneObject
int getID()

Gets the ID of the SimObject

Returns:the unique numeric object ID

Example:

local object = scenetree.findObject(5989)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
print(object:getID())
int getDeclarationLine()

Get the declaration line number

Returns:the declaration line number

Example

local object = scenetree.findObject(5408)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
print(object:getDeclarationLine())
setDeclarationLine(int lineNumber)

Set the declaration line number

Example

local object = scenetree.findObject(5408)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
object:setDeclarationLine(20)
print(object:getDeclarationLine())
string serialize(bool pretty, int formatDepth)

Serialize the object to JSON-String

Parameters

  • bool pretty:
  • int formatDepth: If its less, more objects are written in less rows
Params pretty:if true the string will have return line
Params formatDepth:
 the maximum depth level that should be exported
Returns:json string
local object = scenetree.findObject(5408)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
print(object:serialize(true, 1))

Prints for example:

{"class":"TSStatic",
"persistentId":"2c5a2c1c-caab-4e7b-99ef-c0d5b580a0ea",
"position":[27.1023006439209,-346.4599914550781,36.17470169067383],
"allowPlayerStep":"1",
"rotationMatrix":[5.960464477539063e-08,1,0,-1,5.960464477539063e-08,0,0,0,1],
"shapeName":"levels/port/art/shapes/buildings/port_base_01_b.dae"}
__tostring()

Gets the String of the SimObject

Returns:a LUA string in this format

Example:

local object = scenetree.findObject(5408)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
print(object:__tostring()) -- prints the Unique-ID of the SimObject f.e. 5408
setDefaultAddGroup(string groupName)
  • string groupName: the group name to where to add by default
string getDefaultAddGroup()
Returns:the Default Add Group

Example:

print(SimObject:getDefaultAddGroup()) -- f.e. 6975

class SceneObject

class SceneObject : SimObject
setHidden(bool hidden)
  • bool hidden: set if hidden

Example:

local object = scenetree.findObject(16002)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
-- Sets the object hidden
object:setHidden(false)
bool isHidden()

Checks if the Object is hidden

Returns:hidden

Example

local object = scenetree.findObject(16002)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
print(tostring(object:isHidden()))
setPosition(Point3F pos)

Parameters

  • Point3F pos: the position of the object

Example

local object = scenetree.findObject(16002)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object.
local newPosition = Point3F(4, 10, 40)
object:setPosition(newPosition)
print(object:getPosition())
Point3F getPosition()

Gets the Position of the SceneObject

Returns:position

Example

local object = scenetree.findObject(16002)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object
print(object:getPosition()) -- prints the position of the object in the console
deleteObject()

Removes an object

Example:

local object = scenetree.findObject("supercam")
-- I created a new Camera in the editor and named it "supercam"
print(object:deleteObject()) -- Delete the supercam, i created in Editor
QuatF getRotation()

Gets the rotation of the Object

Returns:(QuadF) Rotation

Example:

local object = scenetree.findObject(5578)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object
print(object:getRotation()) -- Prints f.e. 0, 0, -0.417485, 0.908684
Point3F getScale()

Gets the Scale of the object

Returns:(Point3F) The scale

Example:

local object = scenetree.findObject(5578)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object
print(object:getScale()) -- Get the Scale of the object
setScale(Point3F scale)

Parameters:

  • Point3F scale: the scale to assign to the object

Example

local object = scenetree.findObject(5578)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object
print(object:setScale(Point3F(2,2,2))) -- Doubles the Size of the Object
MatrixF getTransform()

Gets the complete Transform of an object

Returns:MatrixF The transform of an object

Example

local object = scenetree.findObject(5578)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object
print(object:getTransform())

prints in console:

0.651413, -0.758723, 0, 86.3431
0.758723, 0.651413, 0, -387.789
0, 0, 1, 37.1716
setPosRot(float px, float py, float pz, float rx, float ry, float rz, float rw)

Sets the Position and Rotation of the Object to the world Coordinates and a Quatern

  • float px: Position on X axis
  • float py: Position on Y axis
  • float pz: Position on Z axis
  • float rx: Rotation on X axis
  • float ry: Rotation on Y axis
  • float rz: Rotation on Z axis
  • float rw: Rotation on W

Rotation are Quaternion

Example: Gets Object with ID 5578 and set its Position and rotation

local object = scenetree.findObject(5578)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object
object:setPosRot(45, 60, 85, 0, 0, -0.417485, 0.908684)
-- Sets the Position 45, 60, 85 and the Rotation Quad 0, 0, -0.417485, 0.908684
setTransform(MatrixF mat)

Sets the Object -> World transform

MatrixF mat: World transform

Example

local object = scenetree.findObject(5940ö)
-- You are getting the ID from the Editor and clicking on any object
-- or you also can use the name of the object

local matrix = MatrixF()
local point1 = Point3F( 0, 0, 0)
local point2 = Point3F( -0.75, 0.651413, 0)
local point3 = Point3F( 0, 0, 1)
local point4 = Point3F(86.34, -387.789, 37.1716) -- Position
matrix:setColumn(1, point1)
matrix:setColumn(2, point2)
matrix:setColumn(3, point3)
matrix:setColumn(4, point4)
object:setTransform(matrix)
print(object:getTransform())

Prints in Console:

0.651413, -0.758723, 0, 86.3431
0.758723, 0.651413, 0, -387.789
0, 0, 1, 37.1716
Box3F getObjBox()

Gets the Box3F-Object of the SceneObject

Returns:the bounding box of the object

Example

local object = scenetree.findObject(23023)
object:getObjBox()
class SimSet : SimObject
SimSet()

Example

local object = scenetree.findObject(5862)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simset = SimSet()
simset:addObject(object)
print(tostring(simset:at(0).position)) -- Gets the Position of the
-- Object at first Position (Array starts at 0)
addObject(SimObject object)

Add the given object to the set.

  • SimObject object: Object to add to the set.

Example

local object = scenetree.findObject(5862)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simset = SimSet()
simset:addObject(object)
print(tostring(simset:at(0).position)) -- Gets the Position of the
-- Object at first Position (Array starts at 0)
deleteAllObjects()

Deletes all the objects in the set.

Example

local object = scenetree.findObject(5862)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simset = SimSet()
simset:addObject(object)
simset:deleteAllObjects() -- removes all entries of the simset
removeObject(SimObject object)

Remove the given object from the set.

Parameters

  • SimObject object: Object to remove from the set.

Example

local object1 = scenetree.findObject(5862)
local object2 = scenetree.findObject(5869)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simset = SimSet()
simset:addObject(object1)
simset:addObject(object2)
simset:removeObject(object1) -- removes object1 from the simset
int size()
Returns:number in objectList

Example

local object1 = scenetree.findObject(5862)
local object2 = scenetree.findObject(5869)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simset = SimSet()
simset:addObject(object1)
simset:addObject(object2)
print(simset:size()) -- prints 2, because there are 2 members in the SimSet
SimObject getRandom()

Gets a random Object of the SimSet

Returns:random SimObject in the object list

Example

local object1 = scenetree.findObject(5862)
local object2 = scenetree.findObject(5869)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simset = SimSet()
simset:addObject(object1)
simset:addObject(object2)
print(simset:getRandom().position) -- Picks a random Member of SimSet and prints its position to the console
int getCount()

same as size()

SimObject at(int index)

Gets the SimObject at the index

Parameters:

  • int index: The index, you want to get the entry
Returns:the object at the given index.

Example:

local object1 = scenetree.findObject(5862)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simset = SimSet()
simset:addObject(object1)
print(simset:at(0).position) -- prints 2, because there are 2 members in the SimSet
int idAt(int index)

Parameters:

  • int index: The index of the SimSet, you want the ID of
Returns:ID of object at the given index.

Example:

local object1 = scenetree.findObject(5862)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simset = SimSet()
simset:addObject(object1)
print(simset:idAt(0)) -- prints 5862
table getObjects()
Returns:a table with all objects

Example

local object1 = scenetree.findObject(5862)
local object2 = scenetree.findObject(5869)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simset = SimSet()
simset:addObject(object1)
simset:addObject(object2)
local tab = simset:getObjects()
for i, elems in pairs(tab) do
    print(elems)
end

prints in console:

5057.927|A|GELua.print|5862 -- ID of index 1
5057.928|A|GELua.print|5869 -- ID of index 2

class SimGroup

class SimGroup : SimSet
SimGroup()

Creates a new SimGroup

Example:

local object1 = scenetree.findObject(5584)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simgroup = SimGroup()
simgroup:addObject(object1)
addObject(SimObject object)

Add the given object to the set.

  • SimObject object: Object to add to the set.

Example:

local object1 = scenetree.findObject(5584)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simgroup = SimGroup()
simgroup:addObject(object1)
addWithName(SimObject object, char name)

Add the given object to the set.

  • SimObject object: Object to add to the set.
  • string name: name of object

Example

local object1 = scenetree.findObject(5437)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simgroup = SimGroup()
simgroup:addWithName(object1, "testname")
remove(SimObject object)

same as removeObject()

removeObject(SimObject object)

Remove the given object from the set.

Parameters:

  • SimObject object: Object to remove from the set.

Example:

local object1 = scenetree.findObject(5406)
-- You can find the ObjectID at the editor (Or just use the name of the object)
local simgroup = SimGroup()
simgroup:addWithName(object1, "testname")
simgroup:removeObject(object1)
print(simgroup:size()) -- prints 0, because the SimGroup is empty again
findObject(char name)
Parameters:name – name of the object to find

Find object by name

findObjectById(int id)