Blockland Forums > Modification Help
Homing Script
Port:
--- Quote from: otto-san on January 22, 2012, 02:06:20 PM ---if(%mgo == %mco == 1)
is that even a valid if statement or is this another weird torque syntax thing i dont know about
--- End quote ---
It is equally valid as something like this:
if( isFunction( %function = "func_" @ getRandom( 0, 5 ) ) )
call( %function, collapseEscape( "\\x" @ %val SPC "\\\\" ) );
else
%this.success = %this.parent.success = %success = false;
TorqueScript is a very "flexible" language.
Uristqwerty:
--- Quote from: takato14 on January 22, 2012, 02:00:18 PM ---
--- Code: --- while(1)
{
%search=containerSearchNext();
if(%prj.client==%search.client)
{
continue;
}
%mg=%prj.client.minigame;
%mc=%search.client.minigame;
%mgo=isObject(%mg);
%mco=isObject(%mco);
if(%mgo == %mco == 1)
{
if(%mg!$=%mc)
{
continue;
}
}
if(isObject(%search))
{
%obj=%search;
}
break;
}
--- End code ---
--- End quote ---
Looks excessively complicated, though it could have grown that way due to subtle unexpected engine behaviour. I highly doubt it, so would suggest the alternative:
--- Code: --- while((%found = containerSearchNext()))
{
if(%prj.client.minigame == %found.client.minigame)
{
%obj = %found;
break;
}
}
--- End code ---
"%mco=isObject(%mco);" is clearly a typo, intended to be "%mco=isObject(%mc);"
"%mgo == %mco == 1" is likely the same as "(%mgo == %mco) == 1", which is redundant. At first I thought it may have been an attempt to imitate a logical XOR through awkward syntax, but "%mg!$=%mc" clearly expects them to both either be objects or not objects.
Ah, but the layout of that makes me think that there was a problem with minigames that no longer existed, and the solution used seems to be overly complex. So...
--- Code: --- while((%found = containerSearchNext()))
{
%mg = %prj.client.minigame;
%mc = %found.client.minigame;
if((!isObject(%mc) && !isObject(%mg)) || %mc == %mg)
{
%obj = %found;
break;
}
}
--- End code ---
Edit: Oops, missed the part about not targeting self, so it would be
--- Code: --- while((%search = containerSearchNext()))
{
if(%prj.client == %search.client)
{
continue;
}
%mg = %prj.client.minigame;
%mc = %search.client.minigame;
if((!isObject(%mc) && !isObject(%mg)) || %mc == %mg)
{
%obj = %search;
break;
}
}
--- End code ---