Brick counter

Author Topic: Brick counter  (Read 1544 times)

Would it be possible to create some kind of individual brick counter? There are a couple builds that I want to order parts for me to build in real life but I really don't want to count out how many of each individual piece i used.

even if it took some kind of save file brown townyzer rather than doing it in game it would be much appreciated.

thanks
~Poent

type /brick count when in game. it tells you the amount of bricks on the server.

He wants to be able to count the number of a specific brick, i.e how many 1by1by5s there are.

ah...
try photographic memory :P


Wrong section.
You're a cool dude so this goes to all blocklanders: you don't need to comment on a wrong section because the admin will move it anyway

type /brick count when in game. it tells you the amount of bricks on the server.
Its /brickcount, not /brick.

my mistake, i completely forgot that there was a requests section. Either way rkynick was correct when he said i wanted an individual brick count for each specific brick.

Something you could try when building would be every time you use a brick, put another brick of the same type off to the side, and repeat until finishing the build, then count the bricks that are off to the side. :3

Well, a simple loop through all objects in the brick groups and a tally would work.

Code: [Select]
function countbricks()
{
    if(!isobject(mainBrickGroup))return;
    %numfounddata=0;
    for(%i=0;%i<mainbrickgroup.getcount();%i++)
    {
        %group=mainBrickGroup.getobject(%i);
        for(%j=0;%j<%group.getcount();%j++)
        {
            %data=%group.getobject(%j).getdatablock();
            if(%found[%data])%found[%data]++;
            else
            {
                %founddata[%numfounddata]=%data;
                %numfounddata++;
                %found[%data]=1;
            }
        }
    }
    if(%numfounddata)
    {
        for(%i=0;%i<%numfounddata;%i++)
        {
            echo(%found[%founddata[%i]] SPC %founddata[%i].uiname);
        }
    }
    else echo("No bricks to search!");
}


Or if you want to show the numbers to everybody, replace the bottom bit with...
Code: [Select]
    if(%numfounddata)
    {
        for(%i=0;%i<%numfounddata;%i++)
        {
            messageall("","\c2"@%found[%founddata[%i]]@" \c1"@%founddata[%i].uiName);
        }
    }
    else messageall("","No bricks to search!");
}
« Last Edit: June 22, 2008, 09:10:18 PM by !!hammerdwarf!! »

It sounds like the perfect thing. Unfortunately i dont know how to apply it to blockland to get it to count. I tried adding it in the addons folder then running it through the command line in blockland, but it didnt know what to do with the "getDataBlock" function.

How do I go about installing/running this correctly?


Code: [Select]
==>countbricks();
Add-Ons/count.cs (7): Unknown command getDataBlock.
  Object BrickGroup_5361(4501) SimGroup -> SimSet -> SimObject
Add-Ons/count.cs (8): Unable to find object: '' attempting to call function 'get
Count'
No bricks to search!

Oops.
As I wrote it in the text box, then tested it in blockland, when I put the .getdatablock() in there, I put it on the wrong line.
Fixed.

Poent just use this one:

Put it in Add-Ons/client/, run your server, load bricks, then do dumpBricks(); in the console.

It'll output all the bricks to base/brickOutput.txt