After you created the plugin´s barebone you probably want to add a bit of functionality to it, don´t you? Well, then you´re right here. As you know Everybodyedits works with messages, so you´ll mostly need a handler to catch and handle them. In the framework that´s veeery easy. Just type this little code into your OnLoad()-function:
_host.AddMessageHandler(new MessageReceivedEventHandler(OnGotMessage));
(To remove a message handler simply write this little code:)
_host.RemoveMessageHandler(new MessageReceivedEventHandler(OnGotMessage));
This will add a message handler with the function 'OnGotMessage'. This function has to have two parameters: An object sender and the Message m. It looks like this:
private void OnGotMessage(object sender, Message m)
{
}
You handle the messages as usual here.
Another nice functionality is to get the block at a given position in fore- or background. But watch out! This feature is still in beta!
To get the block´s id you simple use this little snippet:
int id = _host._foreground[x, y];
// OR:
int id = _host._background[x, y];
The blockIDs are updated whenever a block, portal, coin door, ... is placed and if the world was reloaded reset or something similar.
Of course these functions provided by the framework will become more! But because the 1.75 - Alpha was the very first release there aren´t so many functions. But because the framework gets updated you won´t have to wait long for updates.
<< Back to Tutorial No. 1
^^ Back to the overview