Author Topic: Datablock Checker - Not counting it correctly [Fixed]  (Read 4311 times)

The count is pretty off once in awhile. I'm not sure why. Fixed



Here is the base code of how it counts and sets the number.


function DBMeter::addDatablockCount(%this,%level){%this.setDatablockCount(%this.getDatablockCount() + %level);}

function DBMeter::setDatablockCount(%this,%level)
{
   %ex = getWord(%this.extent,1);
   %mEx0 = getWord(%this.maxExtent,0);
   %mEx1 = getWord(%this.maxExtent,1);

   %this.count = %level;
   %c = %this.count;
   if(%c < 0) %this.count = 0;
   else if(%c > 4096) %this.count = 4096;

   %mEx2 = %mEx1 * (%this.count/4096);

   %this.resize(getWord(%this.position,0), 310-%mEx2, %mEx0, %mEx2);
   %ex0 = getWord(%this.extent,0);
   %ex1 = getWord(%this.extent,1);

   %this.color = "0 100 0 100";
   if(%ex1 >= %mEx1){%this.extent = %mEx0 SPC %mEx1; %this.color = "100 0 0 100";}
   if(%ex1 < 0) %this.extent = %mEx0 SPC "0";
   DBMeterWord.setText("<just:center>" @ %this.getDatablockCount() @ "<br>DB(s)");
   return mFloor(%this.count);
}

function DBMeter::getDatablockCount(%this)
{
   return mFloor(%this.count);
}
« Last Edit: July 01, 2014, 05:37:30 PM by Advanced Bot »

Have you tried turning it off and on again?

Why are you trying to use the extent of the GUI to determine the count? Why not use global variables?

What's wrong with simply using dataBlockGroup.getCount()?

What's wrong with simply using dataBlockGroup.getCount()?
Because that doesn't work till you actually start the server.

Because that doesn't work till you actually start the server.
I guess I was just thrown off as to the intention of the add-on, because he was in a server

So, since your math is perfectly fine I think it's an issue of .extent saving properly.

Try using DBMeter.resize(getWord(DBMeter.position,0), %mExt, %mEx0, %mEx2)

Also, I suggest using %this instead of the name of the object. I realize you'll probably never have more than one, but it's still weird to program in such a static way.

Also, I'm a little confused on why you don't just set DBMeter.count = %level; instead of doing weird math to derive the count from the size of the panel.

Thanks trinick. Fixed the code and cleaned it up.