Game Development Community

Naming Objects in Levelbuilder

by Harald Scheirich · in Torque Game Builder · 07/04/2006 (4:49 am) · 4 replies

I am just starting out using TGB and I am trying to use some objects I name via the scripting tab in my scripts, but the objects are never found. I am adressing them via $, eg the name I set in Levelbuilder is MyObject and I am trying to set the position via $MyObject.setPosition()

Persistence is unchecked, there are no Datablocks. What am I missing/doing wrong ?

As a followup, I have six objects I want to use in my Scripts but set them up via levelbuilder (a set of dice) what is the cleanest way of dealing with them as a group. Can I just name them Dice_0 through Dice_5 and then use them in my scripts via an array (Dice[1]) ? Are there better solutions ?

Thanks

#1
07/04/2006 (6:24 am)
Use the name you used in level builder without the $. So if you use MyObject in level builder, use MyObject in script as well.

You can also do this to create a global var of your object

function MyObject::onAdd(%this)
{
    $MyObject = %this;
}

Then you can use $MyObject.
#2
07/04/2006 (4:24 pm)
Doug is correct. The reason is that when you name an object TGB doesn't create a variable, it actually creates a namespace for that object.
#3
07/07/2006 (2:55 am)
Thanks for the info, the misunderstanding came from looking at the shooter tutorial where there is a line

$pShip = %this;

but I missed it, both names being the same i jumped the conclusion. I am looking at the sample code and I see that the pShip object is never used even though the assignment of the name is explicitely mentioned in the tutorial. It is always $pShip that is being used. Maybe a note could be added in the PDF file to explain the naming conventions.
#4
07/07/2006 (3:14 pm)
There is a TorqueScript Overview and TorqueScript Reference incuded in your documentation folder.