getId() ); Con::errorf("GameFreak::onFreak(%d,%d)",val, this"> Con::executef() wierdness | Torque Game Engine | Forums | Community | GarageGames.com

Game Development Community

Con::executef() wierdness

by Ron Yacketta · in Torque Game Engine · 06/07/2003 (10:11 am) · 3 replies

O.K I have another stumbling, bumbling, rumbling issue I would like to present to the masses

I am calling Con::executef as follows

char val[24];
dSprintf( val, sizeof(val), "%d", this->getId() );
Con::errorf("GameFreak::onFreak(%d,%d)",val, this->isSelected());
Con::executef(this,3,"onFreak",val,this->isSelected());

then in script I have the following

function GameFreak::onFreak(%this,%selected)
{
   error("GameFreak::onFreak");
   error(%this SPC %selected);
}

the log shows

GameFreak::onFreak(14696576,1) [b]<- From code[/b]
GameFreak::onFreak [b]<- From Script[/b]
1428 1428 [b]<- From Script[/b]

question:

1) why is it that I send "1" as the second arg to onFreak and yet it reports it as the obj ID?
what in gods name is scrogging the damned value?

-Ron

#1
06/07/2003 (10:26 am)
I haven't used Con::executef in a while, but nevertheless some thoughts:
I think you call onFreak with 3 arguments: 1) this 2) val 3) this->isSelected()
However, in the script function, you only use 2 arguments, so the function never receives the this->isSelected().

Maybe you just have to add %val to the script function, so the arguments map correctly:
function GameFreak::onFreak(%this, %val, %selected)
#2
06/07/2003 (10:48 am)
was a two part solution

1)
function GameFreak::onFreak(%this, %val, %selected)
2
Con::executef(this,3,"onFreak",scriptThis(), Con::getIntArg(this->isSelected()));

Thanks Stefan and MikeN!!
#3
05/30/2007 (5:36 am)
Another question...

In my ActorConnection class (derived from GameConnection) I retrieve character names from database using mysql++ API with simple query, returning only names. There are two characters, named "Quessir" and "Shaman", and there is a (theoretically) simple console callback for each one. Everything seems to be fine, but scipt gives random output...

In ActorConnection class (engine) I have:
mysqlpp::Row row = result.fetch_row();
   const char* charName = row.at(0);

   Con::printf(charName);
   if(isMethod("onCharacterListed")) Con::executef(this, 2, "onCharacterListed", charName);

and then, in the script:
function ActorConnection::onCharacterListed(%client, %name)
{
    echo("SCRIPT:" SPC %name);
}

Output on console is:
Quessir
SCRIPT: xm
Shaman
SCRIPT: p^an

Why scipt behaves randomly? Any ideas?