Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2017-04-16 10:54:10

chrisdits
Member
Joined: 2017-04-16
Posts: 3

[Question] Tool for logging placed blocks

I'm trying to create a bot however am getting slowed down drawing blocks.

I'm looking to see what would be required to log the X & Y of placed blocks in a level so I can "con.Send("b", 0, 1, 1, 9);" of all blocks in that structure.

A tool used to be available by Buzzerbee (Block Bot - /viewtopic.php?id=682c) however does not seem to work anymore due to everybody edits updates.

I know it probably sounds simple however I am new to C# and the everybody edits protocols and am struggling to do this myself.

Offline

#2 2017-04-16 11:10:07

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: [Question] Tool for logging placed blocks

Don't forget there's a protocol. Here you can see there's a message you can receive, conveniently called b, just like the message you can send.

I assume you know how to receive messages (like "init").
So when you receive "b", you know that block's layer, x, y, blockid and who placed it.
At this point you can add that data to a collection of choice (e.g. List<>), or process it directly through, for example, if-statements (it would be better practice to put the processing logic in a method, though I won't bother you too much with such practices since you're still learning).

Offline

#3 2017-04-16 11:21:17

chrisdits
Member
Joined: 2017-04-16
Posts: 3

Re: [Question] Tool for logging placed blocks

Something like this?

if (m.Type == "b")
            {
                x = m.GetInt(1);
                y = m.GetInt(2);
                blockid = m.GetInt(3);
                //save to log.txt or something?
            }

Offline

#4 2017-04-16 11:33:02, last edited by LukeM (2017-04-16 11:34:15)

LukeM
Member
From: England
Joined: 2016-06-03
Posts: 3,009
Website

Re: [Question] Tool for logging placed blocks

chrisdits wrote:

Something like this?

if (m.Type == "b")
            {
                x = m.GetInt(1);
                y = m.GetInt(2);
                blockid = m.GetInt(3);
                //save to log.txt or something?
            }

That would work for all of the normal blocks, but you might have to do something special for other blocks

I do this:

            switch (m.Type)
            {
                // Other messages
                case "b":
                    world.BlockPlaced(m, 0);
                    break;
                case "br":
                    world.BlockPlaced(m, 4);
                    break;
                case "bc":
                case "bs":
                case "lb":
                case "pt":
                case "ts":
                case "wp":
                    world.BlockPlaced(m);
                    break;
            }

Then I have a BlockPlaced function that gets the values from the message:

        private void BlockPlaced(PlayerIOClient.Message m, int layerPos = -1)
        {
            object[] args = new object[m.Count - (layerPos >= 0 ? 5 : 4)];
            uint id = 0;
            int l = 0;
            int x = 0;
            int y = 0;

            int i1 = -3;
            for (uint i2 = 0; i2 + 1 < m.Count; i2++)
            {
                if (i2 == layerPos)
                {
                    l = m.GetInt(i2);
                    continue;
                }
                
                if (i1 == -3)
                    x = m.GetInt(i2);
                else if (i1 == -2)
                    y = m.GetInt(i2);
                else if (i1 == -1)
                    id = m.GetUInt(i2);
                else
                {
                    args[i1] = m[i2];
                }

                i1++;
            }
            
            // Handle block placement
        }

This might be overkill for some purposes though, so, depending what you are going to use it for, what you described might be enough

Offline

#5 2017-04-16 12:18:04

chrisdits
Member
Joined: 2017-04-16
Posts: 3

Re: [Question] Tool for logging placed blocks

destroyer123 wrote:
chrisdits wrote:

Something like this?

if (m.Type == "b")
            {
                x = m.GetInt(1);
                y = m.GetInt(2);
                blockid = m.GetInt(3);
                //save to log.txt or something?
            }

That would work for all of the normal blocks, but you might have to do something special for other blocks

I do this:

            switch (m.Type)
            {
                // Other messages
                case "b":
                    world.BlockPlaced(m, 0);
                    break;
                case "br":
                    world.BlockPlaced(m, 4);
                    break;
                case "bc":
                case "bs":
                case "lb":
                case "pt":
                case "ts":
                case "wp":
                    world.BlockPlaced(m);
                    break;
            }

Then I have a BlockPlaced function that gets the values from the message:

        private void BlockPlaced(PlayerIOClient.Message m, int layerPos = -1)
        {
            object[] args = new object[m.Count - (layerPos >= 0 ? 5 : 4)];
            uint id = 0;
            int l = 0;
            int x = 0;
            int y = 0;

            int i1 = -3;
            for (uint i2 = 0; i2 + 1 < m.Count; i2++)
            {
                if (i2 == layerPos)
                {
                    l = m.GetInt(i2);
                    continue;
                }
                
                if (i1 == -3)
                    x = m.GetInt(i2);
                else if (i1 == -2)
                    y = m.GetInt(i2);
                else if (i1 == -1)
                    id = m.GetUInt(i2);
                else
                {
                    args[i1] = m[i2];
                }

                i1++;
            }
            
            // Handle block placement
        }

This might be overkill for some purposes though, so, depending what you are going to use it for, what you described might be enough

Thanks for the help, it was only a bot so i could create some patterns and have a way of saving their blocks into a text document. Got it to work! Thanks!

Offline

Wooted by:
chrisdits1492341484654909

Board footer

Powered by FluxBB

[ Started around 1713607565.8989 - Generated in 0.057 seconds, 12 queries executed - Memory usage: 1.41 MiB (Peak: 1.53 MiB) ]