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-10-25 01:51:44

shadowda
Member
From: somewhere probably.
Joined: 2015-02-19
Posts: 1,015

[question] m.Type

http://capasha.com/eeinformation.php is a very useful website because it has a list for many of everybody edits stuff. 

im not very good with all the correct code using ee info so

# team - UserID joins a team
[0] <Integer> UserID
[1] <Integer> Color, Sheet-List: Disabled = 0, Red = 1, Blue = 2, Green = 3, Cyan = 4, Magenta = 5, Yellow = 6

how would you go about using this for a "if a user becomes a team color do {what ever code i want}"

it may be something like

 
if (m.Type == "team ")
            {
                if (m.GetString(1) = 5)
                say("hello");
            }
            

or maybe its nothing like that at all.


color = #1E1E1E       

latest?cb=20150604065609

Offline

#2 2015-10-25 01:59:33

ZeldaXD
EE Homeboy
From: Cyprus
Joined: 2015-02-15
Posts: 1,539
Website

Re: [question] m.Type

case "team":
      {
             if ((int)m[1] == 5) // if user's team is magenta
                  con.Send("say", "Hello world!");
      }
break;

gLjTZE1.png

Offline

Wooted by:

#3 2015-10-25 02:03:16

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

Re: [question] m.Type

shadowda wrote:

http://capasha.com/eeinformation.php is a very useful website because it has a list for many of everybody edits stuff. 

im not very good with all the correct code using ee info so

# team - UserID joins a team
[0] <Integer> UserID
[1] <Integer> Color, Sheet-List: Disabled = 0, Red = 1, Blue = 2, Green = 3, Cyan = 4, Magenta = 5, Yellow = 6

how would you go about using this for a "if a user becomes a team color do {what ever code i want}"

it may be something like

 
if (m.Type == "team ")
            {
                if (m.GetString(1) = 5)
                say("hello");
            }
            

or maybe its nothing like that at all.

# Means what m.Type or case "": is
[0] means the number that goes inside the "()"
<Integer> means the type the "m.Get" is

You have m.GetString(1) which is wrong as in the website, it's stated as an Integer.
There's also a space after 'team' which shouldn't be there; Here's a sample of what it should look like:

if(m.Type == "team")
{
if (m.GetInt(1) == 5)
{
conn.Send("say", "hello");
}
}

zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

#4 2015-10-25 15:37:41, last edited by Tomahawk (2015-10-25 15:40:22)

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

Re: [question] m.Type

Most coders that know what they're doing use a switch statement rather than lots of ifs to check for different message types:
http://www.dotnetperls.com/string-switch

Like so:

switch (m.Type)
{
   case "team":
      if (m.GetInt(1) == 5)  //If you use m.GetString() to retrieve an integer, it'll crash.
      {
             //Something
      }
      break;
}

And "//Something" will run every time someone joins the magenta team.


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

Offline

#5 2015-10-25 16:16:10

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: [question] m.Type

Tomahawk wrote:

Most coders that know what they're doing use a switch statement rather than lots of ifs to check for different message types:
http://www.dotnetperls.com/string-switch

Like so:

switch (m.Type)
{
   case "team":
      if (m.GetInt(1) == 5)  //If you use m.GetString() to retrieve an integer, it'll crash.
      {
             //Something
      }
      break;
}

And "//Something" will run every time someone joins the magenta team.

Please don't make any assumptions.
Everybody has their own style of coding.
I personally prefer if-statements because I can collapse those (without using ugly block comments).

Offline

#6 2015-10-25 16:22:06, last edited by Tomahawk (2015-10-25 16:22:20)

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

Re: [question] m.Type

den3107 wrote:

I personally prefer if-statements because I can collapse those (without using ugly block comments).

Here's a tip:

#region Collapsible Region which can be given any name
   Code
   Code
   Code
   Code
   Code
#endregion

A switch beats if/else if you're using more than 5 message types.


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

Offline

#7 2015-10-25 16:35:15

shadowda
Member
From: somewhere probably.
Joined: 2015-02-19
Posts: 1,015

Re: [question] m.Type

thanks everyone. i got it.

if (m.Type == "team")
            {
                switch (m.GetInt(1))
                {
                    case 1:
                        con.Send("say", "Fire");
                        break;
                    case 2:
                        con.Send("say", "Water");
                        break;
                    case 3:
                        con.Send("say", "Grass");
                        break;
                    case 5:
                        con.Send("say", "Dark");
                        break;
                    case 6:
                        con.Send("say", "Light");
                        break;
                }
            }

color = #1E1E1E       

latest?cb=20150604065609

Offline

Wooted by: (2)

#8 2015-10-26 00:34:40

den3107
Member
From: Netherlands
Joined: 2015-04-24
Posts: 1,025

Re: [question] m.Type

Tomahawk wrote:
den3107 wrote:

I personally prefer if-statements because I can collapse those (without using ugly block comments).

Here's a tip:

#region Collapsible Region which can be given any name
   Code
   Code
   Code
   Code
   Code
#endregion

A switch beats if/else if you're using more than 5 message types.

that's what I meant with ugly block quotes //forums.everybodyedits.com/img/smilies/tongue
I hate useless comments, even though it's only when it's unfolded.
But yes (mostly with strings) a switch is way faster when you have a decent amount of cases, but this isn't really an argument on the program size you work here.
Pretty much no bot really needs such kinds of optimizations since it's practically impossible to make such a big bot (maybe if you'd make a REAL full-scale RPG where EVERYBODY could play simultaneously and the bot is to monitor multiple rooms).

Offline

#9 2015-10-26 03:54:50

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

Re: [question] m.Type

den3107 wrote:

that's what I meant with ugly block quotes

I hate collapsing if-statements by themselves, just looks weird.


zsbu6Xm.png thanks zoey aaaaaaaaaaaand thanks latif for the avatar

Offline

Xfrogman431445828090553056

Board footer

Powered by FluxBB

[ Started around 1732445244.4683 - Generated in 0.120 seconds, 12 queries executed - Memory usage: 1.55 MiB (Peak: 1.73 MiB) ]