Game Development Community

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.

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


#1
08/30/2013 (8:56 am)
Yes, you are. To execute a script within another script you have to use the exec() function:

// 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.
#2
08/30/2013 (9:09 am)
oops! I'm confused.

i40.tinypic.com/1zlviv4.jpg
#3
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
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
08/30/2013 (6:48 pm)
Ok, so, in scripts/server make a file called initObj.cs:

www.roostertailgames.com/images/Image14.jpg
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.

www.roostertailgames.com/images/Image8.jpg
Next, in scripts/server/gameCore.cs, find GameCore::startGame() and add
InitObj();
at the end of that function.

www.roostertailgames.com/images/Image9.jpg
You should see something similar to this:

www.roostertailgames.com/images/screenshot_001-00000.png
#6
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. :)