Returns Too Early
by Matthew Grint · in Torque Game Engine · 09/17/2005 (2:54 am) · 0 replies
Hi,
This question probably has a very simple answer that my feeble programming cannot find, but I am really stuck on this. I have a function which attempts to find the model to use as the PlayerBody - but I cannot get it to return the correct data. The programming I have done is fairly shoddy, as i'm sure you will all see. What's happening is the function calls getPlayerBody and it returns 'null' before the second function (OnLine) has processed the data and given a reply, how can I get this to return the data ($Race) I want?
function getPlayerBody(%name){
%action = "getbody";
%client.authReturned = false;
%query = "user="@%name@"\t"@
"action="@%action@"\r";
%server = $AuthServer;
%path = $AuthServerPath;
%script = %path @ "game_login.php";
%upd = new HTTPObject(GetBody);
%client.sendObject = %upd; //store object details just in case
%upd.clientid = %client;
%upd.get(%server, %script, %query);
return($Race);
}
}
function GetBody::onLine( %this, %line )
{
if(StrStr(%line, "GlowyBody") != -1)
{
$Race = "GlowyBody";
}
if(StrStr(%line, "OrcBody") != -1)
{
$Race = "OrcBody";
return($Race);
}
else
{
$Race = "GlowyBody";
}
return($Race);
}
Thanks for any help, I really appreciate it!
Matthew Grint
This question probably has a very simple answer that my feeble programming cannot find, but I am really stuck on this. I have a function which attempts to find the model to use as the PlayerBody - but I cannot get it to return the correct data. The programming I have done is fairly shoddy, as i'm sure you will all see. What's happening is the function calls getPlayerBody and it returns 'null' before the second function (OnLine) has processed the data and given a reply, how can I get this to return the data ($Race) I want?
function getPlayerBody(%name){
%action = "getbody";
%client.authReturned = false;
%query = "user="@%name@"\t"@
"action="@%action@"\r";
%server = $AuthServer;
%path = $AuthServerPath;
%script = %path @ "game_login.php";
%upd = new HTTPObject(GetBody);
%client.sendObject = %upd; //store object details just in case
%upd.clientid = %client;
%upd.get(%server, %script, %query);
return($Race);
}
}
function GetBody::onLine( %this, %line )
{
if(StrStr(%line, "GlowyBody") != -1)
{
$Race = "GlowyBody";
}
if(StrStr(%line, "OrcBody") != -1)
{
$Race = "OrcBody";
return($Race);
}
else
{
$Race = "GlowyBody";
}
return($Race);
}
Thanks for any help, I really appreciate it!
Matthew Grint
About the author