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.
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
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
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
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
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
[ Started around 1732397395.1683 - Generated in 0.104 seconds, 12 queries executed - Memory usage: 1.42 MiB (Peak: 1.53 MiB) ]