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

Mudlet vs GMCP - checking a substring against a table

XliXli Member Posts: 354 ✭✭✭ - Distinguished
How can I check for whether a substring within a string exists in a table?

My string is from GMCP, for example:

{
  Char = {
    Items = {
      Add = {
        location = "room",
        item = {
          id = "84684",
          name = "a diminutive fairy",
          attrib = "m"
        }
      }, [some more stuff in the GMCP table] }

I have the value fairy in my table. How can I check for it?

Hiroma tells you, "I just got to listen to someone complain about your deadly axekick being the bane of their existence."
Archdragon Mizik Corten, Herald of Ruin says, "Man, that was a big axk."
Hellrazor Cain de Soulis, Sartan's Hammer says, "Your [sic] a beast."
Tagged:

Comments

  • MannimarMannimar Member Posts: 973
    edited April 2013
    You can use:
    string.match(gmcp.Char.Items.Add.name, "fairy")

    I don't know if there is a more efficient way, but it's what I do for my targeter.

    You can get a whole lot more complicated, especially because many times you want to differentiate between the items in your room versus in your inventory. 

    so for that you'd need an if statement:

    if gmcp.Char.Items.Add.location == "room" then

    whatever you want

    end
  • XliXli Member Posts: 354 ✭✭✭ - Distinguished
    Aha! I had gmcp.Char.Items.Add.item.name instead of gmcp.Char.Items.Add.name

    However, it's not updating when mobs enter and leave the room... apart from looking / ih / etc, is there a way to get it to refresh the table?
    Hiroma tells you, "I just got to listen to someone complain about your deadly axekick being the bane of their existence."
    Archdragon Mizik Corten, Herald of Ruin says, "Man, that was a big axk."
    Hellrazor Cain de Soulis, Sartan's Hammer says, "Your [sic] a beast."
  • MannimarMannimar Member Posts: 973
    edited April 2013
    Thats a completely different tag.

    You're wanting gmcp.Char.Items.Remove

    it's easier to set this up on its own script.

    also item.name should be right. I do mine just a little differently, so I missed typed it.

    You can refresh the list with QL and LOOK as well.

    You'll need to pull from gmcp.Char.Items.List for that
Sign In to Comment.