Bot Problems || Strings

Author Topic: Bot Problems || Strings  (Read 3214 times)

I had to write this script to find the first instance of none and replace it with the thing they bought:

function fillCanteen(%client, %powerup)
{
   %a = getWord(%client.canteen, 0);
   %b = getWord(%client.canteen, 1);
   %c = getWord(%client.canteen, 2);
   if(%a $= "NONE")
   {
      %a = %powerup;
   }
   else if(%b $= "NONE")
   {
      %b = %powerup;
   }
   else if(%c $= "NONE")
   {
      %c = %powerup;
   }
   %client.canteen = %a SPC %b SPC %c;
}


So now it's
if(%upg $= "Artificial")
{
   if(%client.cash < 100)
   {
      %client.chatMessage("\c3You don't have enough money to buy Artificial Crits!");
      %displayMoney = 1;
   }
   else
   {
      %client.chatMessage("\c3You bought a single Artificial Crit canteen.");
      %client.cash -= 100;
      fillCanteen(%client, "CRITS");
   }
}


Thanks!

strPos is perfectly acceptable.
I realize it is, I guess I should have just mentioned that it exists instead. I need to get over some of my minor pet peeves is all, I guess. :)

I realize it is, I guess I should have just mentioned that it exists instead. I need to get over some of my minor pet peeves is all, I guess. :)

If anything, strPos is more correct because the standard C strpos function returns the index of the search string, just like Torque. The standard C strstr function returns a pointer to the search string. But yes, it doesn't really matter in Torque. It's interesting that they even included both of them.

the string strstr is more compressible in a zip file than the string strpos is so therefore i conclude that strstr is superior to strpos
this has been facts with ipquarx™

"pos" is short for "positive". Positive is good. Therefore, strpos is better than strstr.

strstr sounds dumb so strpos is better, obviously. strpos is better than strPos though.