View Single Post
Old 05-22-2010, 10:11 PM   #3
Paul Stevens
Drow Warrior
 

Join Date: July 8, 2003
Location: Madison, Wisconsin
Age: 85
Posts: 296
Default Re: Script debugging

$VAR Count;
Count = 0;

//Nice. Declare a variabel named 'Count' and set it to "0".
// Remember!!!!!! Everthing in GPDL is a string. (White
//lie alert!). At any rate.....GPDL kindly converted the
//zero to a string, saving you two keystrokes and the
//associated shifts.


$WHILE (Count < ($MINUS($PARTYSIZE(), 1)))

//Not too bad.....Let us say the party size is
// three. That is "3". Remember everthing is a
//string. But $MINUS converts strings to numbers
//and back again....So the result is "2".
//This works pretty well....even though you
//meant to compare numbers, you were actually
//comparing strings. Nevertheless, "0" is less
//than "2". "1" is less than "2". In dictionary
//order. So all is well. If the numbers had gotten
//as high as ten, however, we would find that
// "10" is less than "2".
// Perhaps you should have used a numeric
//comparison rather than a string comparison.
// Count <# ($MINUS($PARTYSIZE(), 1))
// And Manikus is right. $MINUS is designed to
// operate on very large numbers. It would be
// a rather slow and inefficient way to subtract
// small numbers ( less than about 2 billion ).

{
$SET_CHAR_STATUS(Count, "2");

//Now it gets complicated. What is count? It
//can mean one of two things!!!!! Neither of which
//is what you want!
//
// In combat it is the combatant number. It probably
//will be equal to 0, 1, 2, 3, etc for the party
//and then continuing with higher numbers for the
//monsters. But you should not count on it.
//
// In adventure it is the unique id of the party
//member and could be anything. 12, 22, 97, 103.
//

Count = (Count + 1);

//Here, my friend, is the big mistake. Remember that
//everything is a string. "0" + "1" is "01";
//"01" + "1" is "011".
//
// You should probably use an arithmetic plus...
// Count = (Count +# 1);

};
$RETURN;

Last edited by Paul Stevens; 05-22-2010 at 10:47 PM.
Paul Stevens is offline   Reply With Quote