Object not created.
by Yue -Rookie Torque 3D- · in Torque 3D Beginner · 08/30/2013 (8:50 am) · 8 replies
Good documentation continuous torque. Obviously I'm doing something wrong.
Object does not appear.
main.cs / / exec file test.cs test.cs
// File test.cs
datablock StaticShapeData(Obj)
{
ShapeFile = "art/shapes/items/kit/healthkit.dts";
testVar = "Simple string, not a stock variable";
};
// Call prodecure Level console.
function Init()
{
$Objeto = new StaticShape()
{
datablock = "Obj";
position = "0.0 0.0 0.0";
rotation = "1 0.0 0.0 0.0";
scale = "1 1 1";
};
}Object does not appear.
About the author
http://www.iris3d.tk -Games Studios- <<I do not speak English: I use the google translator>> My goal as a rookie is knowing Torque 3D
#3
Try this: place your script into /game/scripts/server, then in /game/scripts/server/scriptExec.cs add your exec("./Init.cs") call. Change your Init() function to something like ObjInit() so it is unique. Next, try calling your new ObjInit() at the end of GameCore::startGame(), located in /game/scripts/server/gameCore.cs around line 420.
<edit>
I just tested this in a project I'm working on and it works fine.
08/30/2013 (9:34 am)
Huh, that should work - the only thing I can think of is that there is another function called "Init" that is defined after yours. This would overwrite yours, so it would be called instead.Try this: place your script into /game/scripts/server, then in /game/scripts/server/scriptExec.cs add your exec("./Init.cs") call. Change your Init() function to something like ObjInit() so it is unique. Next, try calling your new ObjInit() at the end of GameCore::startGame(), located in /game/scripts/server/gameCore.cs around line 420.
<edit>
I just tested this in a project I'm working on and it works fine.
#4
==>InitObj();
GameBase::setDatablockProperty - Could not find data block "Obj"
ShapeBase::onAdd - no datablock on shape 4268:StaticShape ((null))
scripts/Prueba.cs (13): Register object failed for object (null) of class StaticShape.
08/30/2013 (10:46 am)
no work, console.log==>InitObj();
GameBase::setDatablockProperty - Could not find data block "Obj"
ShapeBase::onAdd - no datablock on shape 4268:StaticShape ((null))
scripts/Prueba.cs (13): Register object failed for object (null) of class StaticShape.
#5

Add your code, but change the Init() function to InitObj().
In scripts/server/scriptExec.cs, add

Next, in scripts/server/gameCore.cs, find GameCore::startGame() and add

You should see something similar to this:
08/30/2013 (6:48 pm)
Ok, so, in scripts/server make a file called initObj.cs:
Add your code, but change the Init() function to InitObj().
In scripts/server/scriptExec.cs, add
exec("./initObj.cs");at the end of the file.
Next, in scripts/server/gameCore.cs, find GameCore::startGame() and add
InitObj();at the end of that function.

You should see something similar to this:
#6
thanks friend :)
08/30/2013 (8:00 pm)
I appreciate your time and help explain, so I find it easier to continue the documentation.thanks friend :)
#7
08/30/2013 (8:01 pm)
Yeah, but did it work? ;p
#8
08/30/2013 (8:01 pm)
Yes, work perfect. :)
Torque Owner Richard Ranft
Roostertail Games
// relative paths start in /game, so this will exec the myMain.cs script // in /game/scripts/server exec("./scripts/server/myMain.cs"); // you will have to use the correct relative path. exec("./scripts/server/test.cs");Once you have done this you can use anything defined in those files anywhere you need to.