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 2015-03-15 23:43:07, last edited by Psychocrysma (2015-03-16 01:21:57)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Get current block?

Hi, so I was programming a part of my bot where it selects a random block in a certain area and it is supposed to verify if it is already occupied by another block. If it is air, then it places either a crown or a coin.

However, I wasn't able to find anyway to get the current values of a block that is already placed. Is there anyway to do this? Even if it requires to make a list when it connects, it would be very helpful. I seem to understand that it would probably be possible using WPE Pro (A tool I have used many years ago), but that, I am not sure.

In any case, I'd like to know in which triggered event I should add the code as well (I'm guessing it will be in m.Type == "b" or something.

[EDIT1] Also, anyone knows how to place a coin or a crown? I seem to be able to place a block, but not a coin or a crown...

Thanks already~

Offline

#2 2015-03-16 09:05:29

madiik
Member
From: floor above Yuuta
Joined: 2015-02-26
Posts: 514

Re: Get current block?

You need a world deserializer wich deserializes the byte array in the WorldData you get from 'init'
I haven't found a working de-serializer from the web yet, but I don't know about you.


shh i have returned

Offline

#3 2015-03-16 12:39:44

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Get current block?

Then I guess I'll have to search for one working.

Offline

#4 2015-03-17 22:42:16

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: Get current block?

4649's would do well, although, you can make your own deserializer once you acknowledge the way it works. you might want to try

switch (e.Type) // or m.Type
{
    case "init":
        Clipboard.SetText(e.ToString());
        break;
}

Offline

#5 2015-03-18 12:25:37

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Get current block?

DarkDragon4900 wrote:

4649's would do well, although, you can make your own deserializer once you acknowledge the way it works. you might want to try

switch (e.Type) // or m.Type
{
    case "init":
        Clipboard.SetText(e.ToString());
        break;
}

What's 4649's? Also, why does it copy the string to the clipboard? What is this string?

Offline

#6 2015-03-18 21:26:04, last edited by DarkDragon4900 (2015-03-18 21:32:25)

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: Get current block?

Psychocrysma wrote:

What's 4649's?

We're discussing deserialization, and hence so, it refers to 4649's deserializer. there are lots of other deserializers though.


Psychocrysma wrote:

Also, why does it copy the string to the clipboard?

It copies it to the clipboard so you can paste the "init" message, and read it therefore allowing you to understand the way it works.


Psychocrysma wrote:

What is this string?

It is the text form of the init message; containing all the data one would get upon connecting.

[Edit] Also, about placing coins/crowns, you should be able to place them in a way identical to that of placing normal blocks.

con.Send(wKey, 0, x, y, 100);

Offline

#7 2015-03-18 22:26:40, last edited by Psychocrysma (2015-03-19 04:21:33)

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Get current block?

DarkDragon4900 wrote:
Psychocrysma wrote:

What's 4649's?

We're discussing deserialization, and hence so, it refers to 4649's deserializer. there are lots of other deserializers though.


Psychocrysma wrote:

Also, why does it copy the string to the clipboard?

It copies it to the clipboard so you can paste the "init" message, and read it therefore allowing you to understand the way it works.


Psychocrysma wrote:

What is this string?

It is the text form of the init message; containing all the data one would get upon connecting.

[Edit] Also, about placing coins/crowns, you should be able to place them in a way identical to that of placing normal blocks.

con.Send(wKey, 0, x, y, 100);

Thanks. Do you know where I can find his deserializer? That's what I meant by "What's 4649's (deserializer)". That's said, I sure think it will be fun analysing this string.  I know that the "init" contained all data from connection, but what I never realised before is that it could actually be read... I feel dumb.
EDIT1: Is it this one? http://pastebin.com/9uFrYtYp If so, how do I use it to check if it is an air block from an event (m.Type == "say")

Offline

#8 2015-03-19 09:46:15, last edited by DarkDragon4900 (2015-03-19 09:48:43)

DarkDragon4900
Member
Joined: 2015-03-17
Posts: 251

Re: Get current block?

Psychocrysma wrote:

Thanks. Do you know where I can find his deserializer? That's what I meant by "What's 4649's (deserializer)". That's said, I sure think it will be fun analysing this string.  I know that the "init" contained all data from connection, but what I never realised before is that it could actually be read... I feel dumb.
EDIT1: Is it this one? pastebin c0m 9uFrYtYp If so, how do I use it to check if it is an air block from an event (m.Type == "say")

It isn't.
Although, it should work fine.
All you've gotta do is add the blocks you get into a list. (It has variables such as bid, x and y)
And checking for a block is easy.

struct Block {public int x, y, bid;}
private List<Block> worldData = new List<Block>();
//You can add to the block list this way -In case you didn't know- : worldData.Add(new Block{x = /*x?*/, y = /*y?*/, bid = /*block id.*/});

//...

switch (m.Type)
{
    case "say":
        string spl[] = m.GetString(1).Split(' ');
        if (/*player == you && */ spl[0] == ".check" && /* > optional > */ spl.Length > 1)
        {
            int x = int.Parse(spl[1]);//.check x y
            int y = int.Parse(spl[2]);
            foreach (Block b in worldData)
            {
                if (b.x == x && b.y == y)
                    con.Send("say", "/pm psychocrysma The block you specified is" + String.Format(b.bid == 0 ? " empty." : " reserved."));
                                                                                   // bool ? valueIfTrue : valueIfFalse ^
            }
        }
        break;
}

[Edit] Oh right, you can find lots of other deserializers in case this one doesn't suite you. i'm pretty sure there are a few good ones on the forums. and if you would still fail to use them, i can ask tomahawk to give you his deserializer.

Offline

#9 2015-03-20 17:35:06

Psychocrysma
Member
Joined: 2015-02-26
Posts: 46

Re: Get current block?

DarkDragon4900 wrote:
Psychocrysma wrote:

Thanks. Do you know where I can find his deserializer? That's what I meant by "What's 4649's (deserializer)". That's said, I sure think it will be fun analysing this string.  I know that the "init" contained all data from connection, but what I never realised before is that it could actually be read... I feel dumb.
EDIT1: Is it this one? pastebin c0m 9uFrYtYp If so, how do I use it to check if it is an air block from an event (m.Type == "say")

It isn't.
Although, it should work fine.
All you've gotta do is add the blocks you get into a list. (It has variables such as bid, x and y)
And checking for a block is easy.

struct Block {public int x, y, bid;}
private List<Block> worldData = new List<Block>();
//You can add to the block list this way -In case you didn't know- : worldData.Add(new Block{x = /*x?*/, y = /*y?*/, bid = /*block id.*/});

//...

switch (m.Type)
{
    case "say":
        string spl[] = m.GetString(1).Split(' ');
        if (/*player == you && */ spl[0] == ".check" && /* > optional > */ spl.Length > 1)
        {
            int x = int.Parse(spl[1]);//.check x y
            int y = int.Parse(spl[2]);
            foreach (Block b in worldData)
            {
                if (b.x == x && b.y == y)
                    con.Send("say", "/pm psychocrysma The block you specified is" + String.Format(b.bid == 0 ? " empty." : " reserved."));
                                                                                   // bool ? valueIfTrue : valueIfFalse ^
            }
        }
        break;
}

[Edit] Oh right, you can find lots of other deserializers in case this one doesn't suite you. i'm pretty sure there are a few good ones on the forums. and if you would still fail to use them, i can ask tomahawk to give you his deserializer.

Well, I might take you up on your offer.

Offline

#10 2015-03-21 04:56:02

Different55
Forum Admin
Joined: 2015-02-07
Posts: 16,575

Re: Get current block?

Locked on request of owner.


"Sometimes failing a leap of faith is better than inching forward"
- ShinsukeIto

Offline

Different551426910162485134

Board footer

Powered by FluxBB

[ Started around 1732490378.3762 - Generated in 0.077 seconds, 14 queries executed - Memory usage: 1.52 MiB (Peak: 1.67 MiB) ]