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-06-23 05:04:05, last edited by Xfrogman43 (2015-06-23 19:15:03)

Xfrogman43
Member
From: need to find a new home
Joined: 2015-02-15
Posts: 4,174

Writing code

Anybody know of a way to write letters onto the game?

I have code but i would like to understand it.

//This is a command.
                    if (msg.StartsWith("!write "))
                    {
                        string[] strArray = msg.Split(new char[] { ' ' });
                        string Stuffz = msg.ToLower();
                        string Data = msg.Replace("!write ", "");
                        string[] uhthepos = msg.Split(' ');
                        Bitmap bitmap = new Bitmap(Environment.CurrentDirectory+ "RGfont1.bmp");
                        string str2 = uhthepos[4]; //Text
                        int num = Convert.ToInt32(uhthepos[1]); //X from world
                        int num2 = Convert.ToInt32(uhthepos[2]);//Y from world
                        int num3 = Convert.ToInt32(uhthepos[3]); //block
                        int num4 = 0;
                        int num5 = 0;
                        for (var si = 4; si < uhthepos.Length; si++)
                        {
                            str2 = uhthepos[si] + " "; ;
                            for (int i = 0; i < str2.Length; i++)
                            {
                                uint num7 = str2[i];
                                int num8 = (int)((num7 / 0x10) * 10);
                                int num9 = (int)((num7 % 0x10) * 7);
                                bool flag = false;
                                int num10 = 0;
                                while (!flag)
                                {
                                    switch (bitmap.GetPixel(num9 + num10, num8 + num5).R)
                                    {
                                        case 120:
                                            num5 = -1;
                                            flag = true;
                                            break;

                                        case 180:
                                            num5 = -1;

                                            flag = true;
                                            break;

                                        case 0:
                                            conn.Send(roomkey, new object[] { 0, num + num4, num2 + num5, num3 });
                                            Thread.Sleep(15);
                                            break;

                                        case 0x6f:
                                            num5 = -1;
                                            flag = true;
                                            break;
                                    }
                                    if (num5 < 8)
                                    {
                                        num5++;
                                    }
                                    else
                                    {
                                        num4++;
                                        num10++;
                                        num5 = 0;
                                    }

                                }
                                num4++;
                            }
                        }
                    }

zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#2 2015-06-23 06:25:29

Jabatheblob1
Member
Joined: 2015-03-01
Posts: 856

Re: Writing code

It reads the bitmap and if it hits a certain color it will either distinguish if a block will be placed there, if the block will not be placed, or it's trying to search for a block outside of the area the letter fits into.
the calculations in num8 and num9 are to determine the letter and where it is in the bitmap. The rest of the switch and such are building the letters. You can make your own fonts too as long as you know how to re-adjust the calculations to find the letters correctly.


If you would like me to make a bot for you, go here.

Offline

#3 2015-06-23 12:02:16

ewoke
Member
Joined: 2015-02-20
Posts: 412

Re: Writing code

 public static bool ready = false;
        public static string bldatam { get; set; }
        public static int position = 3;
        public static int text_size = 9;
        public static int bid = 9;
        public static List<blocks> b = new List<blocks>();
        public static Connection connection;
       public class blocks
        {
            public int yy;
            public int xx;
            public blocks(int x, int y)
            {
                xx = x; yy = y;
            }
        }
 if (e.Type == "init")
                {
                    bldatam = new string(e.GetString(5).ToCharArray().Select(s => { return (char)((s >= 97 && s <= 122) ? ((s + 13 > 122) ? s - 13 : s + 13) : (s >= 65 && s <= 90 ? (s + 13 > 90 ? s - 13 : s + 13) : s)); }).ToArray());
                    //con.Send("access", "a1x2");
                    ready = true;
                }

                else if (e.Type == "access")
                {
                    Console.WriteLine("ready");
                    ready = true;
                }
                else if (e.Type == "b")
                {
                    blocks q = new blocks(e.GetInt(1), e.GetInt(2));
                    if (b.Contains(q))
                    {
                        b.Remove(q);
                    }
                }

                else if (e.Type == "say")
                {
                    List<string> commands = new List<string>() { "!write", "!size" };
                    if (!(e.GetString(1).Split(' ').Length >= 1)) return;

                    if (commands.Any(s => e.GetString(1).StartsWith(s, StringComparison.OrdinalIgnoreCase)))
                    {
                        string command = commands.Where(s => e.GetString(1).StartsWith(s, StringComparison.OrdinalIgnoreCase)).First();
                        string message = e.GetString(1).Substring(command.Length, e.GetString(1).Length - command.Length);

                        if (!ready) { con.Send("say", "Not ready. No access granted."); return; }

                        switch (command)
                        {
                            case "!write":
                                Bitmap bitmap = new Bitmap(398, text_size);
                                Graphics g = Graphics.FromImage(bitmap);
                                g.FillRectangle(new SolidBrush(Color.Black), 0, 0, bitmap.Width, bitmap.Height);
                                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
                                g.DrawString(message, new Font("Calibri", text_size / 2), new SolidBrush(Color.White), 0, 0);
                                for (int x = 0; x < bitmap.Width; x++)
                                {
                                    for (int y = 0; y < bitmap.Height; y++)
                                    {
                                        Color clr = bitmap.GetPixel(x, y);
                                        if (clr.ToArgb() == -16777216) continue;
                                        b.Add(new blocks(x, position + y));
                                    }
                                }
                                run();
                                position += text_size;
                                break;
                            case "!size":
                                int size;
                                if (int.TryParse(message, out size)) text_size = size;
                                else
                                    con.Send("say", "Invalid font size.");
                                break;
                            case "!c":
                                int color;
                                if (int.TryParse(message, out color)) bid = color;
                                else
                                    con.Send("say", "Invalid value");
                                break;
                        };

                    }
                }
            };
         

creds to atilla our lord and saviour


if you can read this....good for you

Offline

#4 2015-06-23 16:53:14

Tomahawk
Forum Mod
From: UK
Joined: 2015-02-18
Posts: 2,835

Re: Writing code

That's a ridiculous way to rot13, ewoke ^^


One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.

Offline

Tomahawk1435074794515571

Board footer

Powered by FluxBB

[ Started around 1714061522.409 - Generated in 0.098 seconds, 12 queries executed - Memory usage: 1.42 MiB (Peak: 1.52 MiB) ]