Script
by _Ricardo_Junior · in Torque Game Engine · 09/24/2007 (7:34 am) · 3 replies
Hi all,
Well, I'm making tests using starter.fps toolkit. In this folder, I put a file with this code:
datablock ItemData(ObjTeste)
{
shapeFile = "~/data/shapes/items/healthPatch.dts";
mass = 1;
friction = 1;
};
function InsereObjTeste()
{
%shape = new Item() {
datablock = ObjTeste;
rotation = "0 0 1 0";
};
// Insere na missao do torque
MissionCleanup.add(%shape);
%shape.setTransform("-90 -2 20 0 0 1 0");
echo("Inserindo elemento " @ %shape);
return (%shape);
}
function MoveObjeto(%shape, %dist)
{
%xfm = %shape.getTransform();
%lx = getword(%xmf, 0);
%ly = getword(%xmf, 1);
%lz = getword(%xfm, 2);
%lx += %dist;
%shape.setTransform(%lx SPC %ly SPC %lz SPC "0 0 1 0");
}
function ExecutaMovimento()
{
%ms = InsereObjTeste();
MoveObjeto(%ms, 15);
}
Then, I start my starter fps and in the console I execute exec("starter.fps/teste.cs");
It compiles without problem and load the compiled file, as said in the console.
The problem is when I try, in the console, this comand:
$dd = InsereObjTeste();
I receive an error message, saying that this function does not exist. Does someone knows why this occour?
Thanks a lot.
Jose Ricardo
Well, I'm making tests using starter.fps toolkit. In this folder, I put a file with this code:
datablock ItemData(ObjTeste)
{
shapeFile = "~/data/shapes/items/healthPatch.dts";
mass = 1;
friction = 1;
};
function InsereObjTeste()
{
%shape = new Item() {
datablock = ObjTeste;
rotation = "0 0 1 0";
};
// Insere na missao do torque
MissionCleanup.add(%shape);
%shape.setTransform("-90 -2 20 0 0 1 0");
echo("Inserindo elemento " @ %shape);
return (%shape);
}
function MoveObjeto(%shape, %dist)
{
%xfm = %shape.getTransform();
%lx = getword(%xmf, 0);
%ly = getword(%xmf, 1);
%lz = getword(%xfm, 2);
%lx += %dist;
%shape.setTransform(%lx SPC %ly SPC %lz SPC "0 0 1 0");
}
function ExecutaMovimento()
{
%ms = InsereObjTeste();
MoveObjeto(%ms, 15);
}
Then, I start my starter fps and in the console I execute exec("starter.fps/teste.cs");
It compiles without problem and load the compiled file, as said in the console.
The problem is when I try, in the console, this comand:
$dd = InsereObjTeste();
I receive an error message, saying that this function does not exist. Does someone knows why this occour?
Thanks a lot.
Jose Ricardo
#2
It's not an error. It's only a shape creation. If you look, this bracket is from new Item and not from function InsereObjTeste.
Thanks.
Jose Ricardo
09/24/2007 (12:27 pm)
Hi Orion,It's not an error. It's only a shape creation. If you look, this bracket is from new Item and not from function InsereObjTeste.
Thanks.
Jose Ricardo
#3
to preserve indenting in forum posts,
you can put the stuff inside a [ code ] ... [ /code ] pair. (except w/o spaces)
to be sure the code is compiling, you could try adding an echo() right above the function() statement.
09/24/2007 (1:15 pm)
Oh you're right; sorry.to preserve indenting in forum posts,
you can put the stuff inside a [ code ] ... [ /code ] pair. (except w/o spaces)
to be sure the code is compiling, you could try adding an echo() right above the function() statement.
Associate Orion Elenzil
Real Life Plus
function InsereObjTeste() { %shape = new Item() { datablock = ObjTeste; rotation = "0 0 1 0"; }; // <---------------------------------- get rid of the ";"edit - whoops, i was counting the braces wrong; this ain't the problem.