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
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
#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
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.
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.
Torque Owner Doug Linley
You can also do this to create a global var of your object
function MyObject::onAdd(%this) { $MyObject = %this; }Then you can use $MyObject.