Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

GMCP

RyzackRyzack Posts: 35Member ✭✭ - Stalwart
So, I'm not entirely sure that I need to ask this here, but I figured its good a place as any. I've been looking over the IRE document that they have on GMCP, and I was wondering if anyone would mind explaining what GMCP actually is, how I can use it, and ways to script with it, because thus far I haven't exactly been able to find out how to do that yet. 
image
Tagged:

Comments

  • NizarisNizaris The Holy City of MhaldorPosts: 537Member ✭✭✭✭✭ - Grand Achaean
    edited September 2013
    GMCP communicates information in a sort of "sub-channel" to your client that you don't see along with everything else. Think of it as a subliminal message for computers.

    The idea is to make an interface for Achaea that is nicer for programming, but doesn't break immersion because it's not communicated in the same channel as everything else you see on screen.

    The best way to learn GMCP is to play with it, rather than reading it. Here's some GMCP code here. This code is actually what the server sends to the client:

    {
      Char = {
        Items = {
          Add = {
            location = "inv",
            item = {
              id = "270261",
              name = "a broken blade piece",
              attrib = "t"
            }
          },
          Remove = {
            location = "room",
            item = {
              id = "270261",
              name = "a broken blade piece",
              attrib = "t"
            }
          },
          Update = {
            location = "inv",
            item = {
              id = "78640",
              name = "a wicked-looking daegger"
            }
          },
        }
      }
    }

    Each of these items is a variable that can be programmed with directly in Mudlet. For example, if I wanted to get the id# of my 'broken blade piece', I could reference this variable: gmcp.Char.Items.Add.item.id, and that would always give me the id number of the last item to be added to the inventory. Notice what the periods do there: they let you reference items deeper in the table.

    Whenever you call these variables, you treat them like any other variable, and that means leaving them out of quotes. One particularly useful variable is this one:

    gmcp.Room.Info.name --> the name of your current room.

    I like to put that variable in things like party reports to say what direction I'm shooting in, and from which room. For example:

    send("pt SHOT " .. target " " .. shootDirection .. " from " .. gmcp.Room.Info.name)

    Might send something like, "pt SHOT Antidas up from Before two towering mountains".

    But, going back to playing with GMCP, if you're using SVO, you just need to do a 'vlua gmcp' from the command line to see the whole table. Otherwise, make an alias to do display(gmcp). Then, start exploring the table, and see what useful stuff you find.
    image
  • NizarisNizaris The Holy City of MhaldorPosts: 537Member ✭✭✭✭✭ - Grand Achaean
    A really helpful example that I like:

    Trigger: ^You try and fail to follow (\w+)$
    send("tell " .. matches[2] .. " Lost you at: " .. gmcp.Room.Info.name)

    This tells whomever you were following EXACTLY where they left you at.
    image
  • DolomarDolomar Posts: 33Member ✭✭✭ - Distinguished
    Just an additional comment--gmcp isn't actually 'captured' by your client until you make an event handler for that gmcp event. display(gmcp) will return nil unless you have at least one gmcp event handler. You can also run functions on gmcp events--I have one, for example, that runs on the gmcp.Room event and tells me whenever my area changed to something it wasn't before, very useful!
  • RyzackRyzack Posts: 35Member ✭✭ - Stalwart
    How would I by chance find my way into seeing what all the balances are that GMCP tracks?
    image
  • DolomarDolomar Posts: 33Member ✭✭✭ - Distinguished
    You can make an alias to do:

     display(gmcp)

    which will show you the full table. As far as I know, though, Achaea's gmcp doesn't track balances at all. I know other games do--Lithmeria has -all- of them for example.
    RyzackEldDalran
  • JonathinJonathin Grand Rapids, MIPosts: 3,263Member @@ - Legendary Achaean
    I have no idea if you're using Mudlet, but I wrote this last December.


    My site will remain up, but will not be maintained. The repository will continue to have scripts added to it if I decide to play another game. Maybe I'll see you around in Starmourn!
    Tutorials and scripts  The Repository

Sign In to Comment.