Plot Plugin

Discussion in 'Plugin Development' started by Dragonphase, Jan 19, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Dragonphase

    Hello. I am attempting to create a plot plugin, whereby all plots in the world can only be built in if the player claims it. I know there are several plugins out there that do just this, but none are quite designed for me because my world is sectioned into two parts - an over-world and a basement.

    So I started to develop my own to do this - slowly designing the plugin through a means of pseudo code and general text to visualize how it will run. Here's a snippet of code I have so far, and a picture to represent what I'm trying to do and what the code will do. As my plots are divided, a Y variable is to be defined in the layer.

    The plugin should start from the very center of the map (0, 0) and expands out depending on the amount of plots, the width and the road width, like so (the black square is the plot coverage):

    [​IMG]

    With this code, I iterate through a direction (i), and add the plot to the PlotList:

    Code:
    public Layer(World world, double y, int plots, int plotWidth, int plotHeight, int roadWidth){
            double X = 0;
            double Y = y;
            double Z = 0;
            for (int i = 0; i < 4; i ++){
                for (int j = 1; j < plots+1; j ++){
                    switch (i){
                        case 0:
                            Z = Z - j*plotWidth - roadWidth;
                            break;
                        case 1:
                            X = X + j*plotWidth + roadWidth;
                            break;
                        case 2:
                            Z = Z + j*plotWidth + roadWidth;
                            break;
                        case 3:
                            X = X - j*plotWidth - roadWidth;
                            break;
                        default:
                            break;
                    }
                    PlotList.add(new Plot(world, X, Y, Z, plotHeight, plotWidth));
                }
            }
        }
    0 = N
    1 = E
    2 = S
    3 = W

    And here is a picture of what this code will actually do:

    [​IMG]

    So can anyone point me in the right direction, as to how to run through each plot so it covers the entire map?
     
  2. Offline

    camyono

Thread Status:
Not open for further replies.

Share This Page