Author Topic: "$server::brickCount" does not work  (Read 5322 times)

But Port's says how to do it more efficiently.
He was pointing me in the correct direction by showing me what to do and where I went wrong. I needed help, and he gave it. Yeah, we know Port's does it more efficiently, but Bluetooth was showing me how to do it the way that I did it originally.

He was pointing me in the correct direction by showing me what to do and where I went wrong. I needed help, and he gave it. Yeah, we know Port's does it more efficiently, but Bluetooth was showing me how to do it the way that I did it originally.
Even if you consider the fact that the code gives incorrect results...
It's still a really bad way to do it.
Think about it. Even if it were to give correct results.
You're looping through a group, using .getCount() to check if you counted them all, setting subcount to the loop count.
You don't need to loop till the loop count is the brick count when you already have a function that gives the count right in the loop function, that you're calling every single time you're resetting the subcount.

If you're going to do a manual count, and not use the method Port posted, here you go.

Code: [Select]
%total = 0; //Set the count to 0 for whatever reason. Probably not necessary.
%groupcount = MainBrickGroup.getCount(); //Get the count once. Inefficient to call this function each check.
for(%i = 0; %i < %groupcount; %i++) //Loop through all the brick groups.
%total+=MainBrickGroup.getObject(%i).getCount(); //Add the number of objects in each brick group.
echo(%total); //loving done.

If you're going to do a manual count, and not use the method Port posted, here you go.

Code: [Select]
%total = 0; //Set the count to 0 for whatever reason. Probably not necessary.
%groupcount = MainBrickGroup.getCount(); //Get the count once. Inefficient to call this function each check.
for(%i = 0; %i < %groupcount; %i++) //Loop through all the brick groups.
%total+=MainBrickGroup.getObject(%i).getCount(); //Add the number of objects in each brick group.
echo(%total); //loving done.
How is this not using the method Port posted? It's almost the exact same thing except there's no brackets, the variables are renamed, and there's an echo at the end.

How is this not using the method Port posted? It's almost the exact same thing except there's no brackets, the variables are renamed, and there's an echo at the end.
Oh, I didn't read previous posts, I thought he posted this:

getBrickCount() is what you want. No need to loop through mainBrickGroup.

Either way. There's zero point to teaching people bad methods, and even less point if it produces incorrect results.

Lol guys, calm down, I was literally just showing him how to add the values, that's all.

Lol guys, calm down, I was literally just showing him how to add the values, that's all.
And did it wrong.
I would've been nice about it if you'd have at least had a correct outcome.