ConsoleMethod problem
by Anthony McCrary · in Torque Game Engine · 05/19/2002 (4:03 pm) · 10 replies
I can't seem to get the ConsoleMethod to actually add the method to the console.
Could someone point out what I am doing wrong? thanks
*changed the 1,1 to 2,2 still no dice*
bool muscleCar::gearShiftUp() {
if(mDataBlock->currentTransmissionGear == 5) {
return false;
} else {
mDataBlock->currentTransmissionGear++;
return true;
}
}
ConsoleMethod(muscleCar, gearShiftUp, bool, 2, 2, "obj.gearShiftUp()")
{
muscleCar* car = static_cast<muscleCar*>(object);
bool shiftResult = car->gearShiftUp();
if(shiftResult) {
return true;
} else {
return false;
}
}Could someone point out what I am doing wrong? thanks
*changed the 1,1 to 2,2 still no dice*
About the author
#2
05/19/2002 (4:22 pm)
Nope still doesn't work :(
#3
umm ok so why not?
what does it say when you run the function?
(the console error)
if Nothing is said.. then it prolly Is running :)
if it is not giving console error pop in a ,
Con::printf("or something");
05/19/2002 (4:24 pm)
?umm ok so why not?
what does it say when you run the function?
(the console error)
if Nothing is said.. then it prolly Is running :)
if it is not giving console error pop in a ,
Con::printf("or something");
#4
05/19/2002 (4:28 pm)
(0): Unknown Command gearShiftUp
#5
{
ClassName * bla = static_cast( object );
bla->ClassPublicFunctionCall();
}
2,2 to get object.
3,3 to pass in 1 arg
3,3 to pass in 2 args.....
05/19/2002 (4:32 pm)
ConsoleMethod(ClassName, ConsoneFunctionName, ReturnType, 2, 2, "help text"){
ClassName * bla = static_cast
bla->ClassPublicFunctionCall();
}
2,2 to get object.
3,3 to pass in 1 arg
3,3 to pass in 2 args.....
#7
dataBlock = DefaultCar;
client = %this;
};
That's the code I am using (like racing mod).
Then in console i am typing
DefaultCar.gearShiftUp();
05/19/2002 (4:40 pm)
%player = new muscleCar() {dataBlock = DefaultCar;
client = %this;
};
That's the code I am using (like racing mod).
Then in console i am typing
DefaultCar.gearShiftUp();
#8
you should open the editor..
and find the number on your object..
use the number
1379.gearShiftUp();
like that.
then you can see what to do.
Edit:
Besides you are trying to use the DataBlock to call that function when you defined it for the class no?
P.S. if it was working I think you would have shifted Every DefaultCar up a gear :)
05/19/2002 (4:43 pm)
hmm I dont know i've never tried to access object's like that .. does it work?you should open the editor..
and find the number on your object..
use the number
1379.gearShiftUp();
like that.
then you can see what to do.
Edit:
Besides you are trying to use the DataBlock to call that function when you defined it for the class no?
P.S. if it was working I think you would have shifted Every DefaultCar up a gear :)
#9
Thanks guys :)
Is there a variable that has your player's id number?
like %clientid
05/19/2002 (4:48 pm)
Awesome, I did a dump() and the method shows up now.Thanks guys :)
Is there a variable that has your player's id number?
like %clientid
#10
..
use [object].getId(); to resolve id.
you can create a script variable anywhere you like to store or pass it I guess .. more research into this could prove a variable is available *shrug* :)
great you got it going!
05/19/2002 (5:02 pm)
hmm not for the most part I dont think..
use [object].getId(); to resolve id.
you can create a script variable anywhere you like to store or pass it I guess .. more research into this could prove a variable is available *shrug* :)
great you got it going!
Torque Owner Badguy
is the problem, im sure you'll need at least a 2, 2
that should work.
Edit:
line 233 engineoverview.txt