/clearmap

Re: /clearmap

Postby Warren1001 » 12 Jun 2013, 03:51

ismellike wrote:Take out the "for(ushort z" part and on the inside of the fors put this
Set ushort z to where the wall will be.
Code: Select all
p.level.Blockchange(p,x,y,z,Block.blackrock);

I'm still confused. Let me try adding more detail.
How can I erase the ENTIRE map and add walls and a bottom to it? Same thing as pixel theme for /newlvl... but for the current level.
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: /clearmap

Postby ismellike » 12 Jun 2013, 15:56

Here you go, I added some stuff to make it faster.

Code: Select all
using System;
namespace MCDzienny
{
    public class CmdClearmap : Command
    {
        public override string name { get { return "clearmap"; } }
        public override string shortcut { get { return "cm"; } }
        public override string type { get { return "build"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
        public override bool ConsoleAccess { get { return false; } }

        public override void Use(Player p, string message)
        {
            int x = p.level.width - 1, y = p.level.height - 1, z = p.level.depth - 1;
            if (message == "")
            {
                p.level.Instant = true;
                Command.all.Find("cuboid").Use(p, "air");
                Command.all.Find("click").Use(p, "1 "+y+" "+(z-1));
                Command.all.Find("click").Use(p, (x-1)+" 1 1");
                Player.SendMessage(p, Server.DefaultColor + "Map has been cleared except for the ground and walls.");
                p.level.Instant = false;
                Command.all.Find("reveal").Use(p, "");
            }
            else if (message == "all")
            {
                p.level.Instant = true;
                Command.all.Find("cuboid").Use(p, "air");
                Command.all.Find("click").Use(p, "0 "+y+" "+z);
                Command.all.Find("click").Use(p, x+" 0 0");
                Player.SendMessage(p, Server.DefaultColor + "Map has been completely cleared.");
                p.level.Instant = false;
                Command.all.Find("reveal").Use(p, "");
            }
            else if (message == "ground")
            {
                p.level.Instant = true;
                Command.all.Find("cuboid").Use(p, "air");
                Command.all.Find("click").Use(p, "0 "+y+" "+z);
                Command.all.Find("click").Use(p, x+" 1 0");
                Player.SendMessage(p, Server.DefaultColor + "Map has been cleared except for the ground.");
                p.level.Instant = false;
                Command.all.Find("reveal").Use(p, "");
            }
            else if (message == "pixel")
            {
                p.level.Instant = true;
                Command.all.Find("cuboid").Use(p, "white walls");
                Command.all.Find("click").Use(p, x+" " + y + " " + z);
                Command.all.Find("click").Use(p, "0 1 0");
                Command.all.Find("cuboid").Use(p, "adminium");
                Command.all.Find("click").Use(p, "0 0 0");
                Command.all.Find("click").Use(p, x+" 0 "+z);
                p.level.Instant = false;
                Command.all.Find("reveal").Use(p, "");
            }
            else
            {
                Help(p);
            }
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/clearmap - clears map except for ground and walls.");
            Player.SendMessage(p, "/clearmap all - clears map completely.");
            Player.SendMessage(p, "/clearmap ground - clears map except for ground.");
            Player.SendMessage(p, "/clearmap pixel - creates a pixel layout");
        }
    }
}
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /clearmap

Postby Warren1001 » 12 Jun 2013, 16:01

ismellike wrote:Here you go, I added some stuff to make it faster.

Code: Select all
using System;
namespace MCDzienny
{
    public class CmdClearmap : Command
    {
        public override string name { get { return "clearmap"; } }
        public override string shortcut { get { return "cm"; } }
        public override string type { get { return "build"; } }
        public override bool museumUsable { get { return false; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }
        public override bool ConsoleAccess { get { return false; } }

        public override void Use(Player p, string message)
        {
            int x = p.level.width - 1, y = p.level.height - 1, z = p.level.depth - 1;
            if (message == "")
            {
                p.level.Instant = true;
                Command.all.Find("cuboid").Use(p, "air");
                Command.all.Find("click").Use(p, "1 "+y+" "+(z-1));
                Command.all.Find("click").Use(p, (x-1)+" 1 1");
                Player.SendMessage(p, Server.DefaultColor + "Map has been cleared except for the ground and walls.");
                p.level.Instant = false;
                Command.all.Find("reveal").Use(p, "");
            }
            else if (message == "all")
            {
                p.level.Instant = true;
                Command.all.Find("cuboid").Use(p, "air");
                Command.all.Find("click").Use(p, "0 "+y+" "+z);
                Command.all.Find("click").Use(p, x+" 0 0");
                Player.SendMessage(p, Server.DefaultColor + "Map has been completely cleared.");
                p.level.Instant = false;
                Command.all.Find("reveal").Use(p, "");
            }
            else if (message == "ground")
            {
                p.level.Instant = true;
                Command.all.Find("cuboid").Use(p, "air");
                Command.all.Find("click").Use(p, "0 "+y+" "+z);
                Command.all.Find("click").Use(p, x+" 1 0");
                Player.SendMessage(p, Server.DefaultColor + "Map has been cleared except for the ground.");
                p.level.Instant = false;
                Command.all.Find("reveal").Use(p, "");
            }
            else if (message == "pixel")
            {
                p.level.Instant = true;
                Command.all.Find("cuboid").Use(p, "white walls");
                Command.all.Find("click").Use(p, x+" " + y + " " + z);
                Command.all.Find("click").Use(p, "0 1 0");
                Command.all.Find("cuboid").Use(p, "adminium");
                Command.all.Find("click").Use(p, "0 0 0");
                Command.all.Find("click").Use(p, x+" 0 "+z);
                p.level.Instant = false;
                Command.all.Find("reveal").Use(p, "");
            }
            else
            {
                Help(p);
            }
        }
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/clearmap - clears map except for ground and walls.");
            Player.SendMessage(p, "/clearmap all - clears map completely.");
            Player.SendMessage(p, "/clearmap ground - clears map except for ground.");
            Player.SendMessage(p, "/clearmap pixel - creates a pixel layout");
        }
    }
}

I guess there's no way to do it the way I'm doing it?
Code: Select all
            if (split2 == "walls")
            {
               ushort bottomX = 1;
               ushort bottomY = 1;
               ushort bottomZ = 1;
               
               ushort topX = 62;
               ushort topY = 63;
               ushort topZ = 62;
               
               for (ushort x = bottomX; x <= topX; ++x)
               {
                  for (ushort y = bottomY; y <= topY; ++y)
                  {
                     for (ushort z = bottomZ; z <= topZ; ++z)
                     {
                        if (p.level.GetTile(x, y, z) != Block.air)
                        {
                           p.level.Blockchange(p, x, y, z, Block.air);
                        }
                     }
                  }
               }
               Player.SendMessage(p, "Map edited.");
            }

I would like to be able to use ^ that method to add adminium walls all the way around, but I'm not sure of a way that would work and not conflict with the previous erasing the map method...
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: /clearmap

Postby ismellike » 12 Jun 2013, 16:27

You could do it like that by taking out a dimension, depending on where the wall is, then change some values.

It would also probably be laggier and harder to make

Here is just a one wall example

Code: Select all
            ushort x = p.level.width, y = p.level.height, z = p.level.depth;
            x -= 1; y -= 1; z -= 1;
            //on a 64x64x64 map ^ those would be 63,63,63
            ushort bottomX = 1;
            ushort bottomY = 1;
            ushort bottomZ = 1;

            ushort topX = (ushort)(x - 1); //62
            ushort topY = 63;
            ushort topZ = (ushort)(z - 1); //62

            for (ushort xx = bottomX; x <= topX; ++x) //map was cleared with air
                for (ushort yy = bottomY; y <= topY; ++y)
                    for (ushort zz = bottomZ; z <= topZ; ++z)
                        if (p.level.GetTile(x, y, z) != Block.air)
                        {
                            p.level.Blockchange(p, x, y, z, Block.air);
                        }
            for (ushort xx = bottomX; x <= topX; ++x) //one wall
                for (ushort yy = bottomY; y <= topY; ++y)
                {
                    p.level.Blockchange(p, x, y, z, Block.blackrock);
                }
            Player.SendMessage(p, "Map edited.");
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /clearmap

Postby Warren1001 » 12 Jun 2013, 19:06

Error from the beginning again -.- No matter what I add/remove/change I keep getting it.
I would like for it if you type anything thats not suppose to be typed, it would send them to the help section.
Code: Select all
if (split1 != "64" || split1 != "128" || message.IndexOf(' ') == -1)
         {
            Player.SendMessage(p, "&6Invalid &7dimension&6. Valid &7dimensions &6are: &764 &6and &7128&6.");
            Player.SendMessage(p, "&4/mpe &6(&7dimension&6) (&9type&6)");
            return;
         }
         if (split1 == "64")
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: /clearmap

Postby ismellike » 12 Jun 2013, 19:11

Ok to do that you would do something like this

you will need to make use of the and && instead of or ||
Code: Select all
if(split1!="something"&&split1!="something_else") //these are your options right here
{
  Help(p); //send them to help
}
What a beast...
User avatar
ismellike
Coder
 
Posts: 731
Joined: 31 Oct 2012, 04:04
Location: Kansas

Re: /clearmap

Postby Warren1001 » 12 Jun 2013, 19:15

ismellike wrote:Ok to do that you would do something like this

you will need to make use of the and && instead of or ||
Code: Select all
if(split1!="something"&&split1!="something_else") //these are your options right here
{
  Help(p); //send them to help
}

oooooh okie :3
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: /clearmap

Postby Warren1001 » 12 Jun 2013, 19:21

Still, unless I type it 100% right, it gives me the Outofwhatever error.
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: /clearmap

Postby Warren1001 » 12 Jun 2013, 19:34

Warren1001 wrote:Still, unless I type it 100% right, it gives me the Outofwhatever error.

Scratch that, it'll give the help menu if i type /mapedit 64 with a space and anything else. if i type /mapedit 64 alone, no space following, or anything less, it gives an error.
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

Re: /clearmap

Postby Warren1001 » 12 Jun 2013, 23:19

I decided to rewrite the entire thing. This is what I've got so far which should make every function work. I can type /mapedit and it'll give me the 3 Player.SendMessages, I can type /mapedit 64 and it'll do the same thing, but if I type anything after that, I get the same error as before:

Error:
Spoiler:


Command:
Spoiler:
Warren1001
 
Posts: 197
Joined: 08 Aug 2012, 03:50

PreviousNext

Return to Help in Coding

Who is online

Users browsing this forum: No registered users and 3 guests

cron