GMCP settarget?

I dug through the GMCP documentation and didn't see anything on this. Is there a way to use GMCP to do the same thing as the SETTARGET command? I have a script to send my target kept in the client to Achaea with SETTARGET, but sometimes thing will happen that cause the command to be sent several times, which is problematic to gag correctly. Can anyone help me get around this?


  • What client are you using? What exactly are you having issues gagging?
  • My bad. I'm using mudlet. I have to gag the Target set to: 12345 (a denizen) as well as the extra prompt. I'm using event handlers to tell the client when to use SETTARGET, and sometimes it'll raise that event a bunch of times, so it has to delete a bunch of lines at once, and it something like a multiline tell comes through at that exact moment, it can mess up. This is why I'm trying to avoid gagging altogether.
  • Thanks! I'd never seen that page, it'll be super helpful in the future I'm sure. I'm having trouble sending the command though.

    So my target I want to send is stored in targetList[1], so I tried:
    sendGMCP([[IRE.Target.Set "]]..targetList[1]..[["]])
    That didn't work, so I tried messing around with just sending it literally
    sendGMCP([[IRE.Target.Set ]]..[["bill"]])
    sendGMCP(IRE.Target.Set "bill")
    sendGMCP([[IRE.Target.Set "bill"]])
    sendGMCP("IRE.Target.Set bill")

    None of these worked. What am I not understanding here?
  • edited July 2015
    Did you turn the module on? sendGMCP([[Core.Supports.Add ["IRE.Target 1"] ]])
  • That was the problem, thank you so much! That would've taken me forever to figure out.
  • I spoke too soon, it works sometimes, but at least I know that the gmcp portion works. Here's the function that I'm using. It's called by an event handler. The same event handler causes a label in my window to update with the current target's name. It is working correctly every time, but this function isn't. It tends to work when I go from not having a target to having a target, but not usually when I have a target and switch to a different one.

    function achaeaTarget ()

       if targetList[1] then

          sendGMCP([[IRE.Target.Set "]]..targetList[1]..[["]])

       end -- if

    end -- achaeaTarget

  • Do you use a target ID or something generic like pig as your target? There are some issues with it. Tynil told me this: "The issue is if you SETTARGET NONE, your target is automatically set to the next thing you hit by number. And then never changes unless you SETTARGET again. Works fine if you do something more generic, like SETTARGET UNDEAD, then hunting only undead stuff."

    But I am unsure if that is related
  • edited July 2015
    I'm using just the number, so it's send IRE.Target.Set "123456". It was never setting to nothing. After looking at the debugger I noticed that it was raising my target update event like 50 times instead of just once and I'm not really sure why, and I suspect this is related to the problem. What happens is that I have a function to update my target that runs when I receive gmcp.Char.Items.List, and this function has my raise target event in it. For some reason when this runs it's raising that event way too many times. I've got a workaround to just use SETTARGET when I actually start hitting something, so it's easier to gag properly, but it's still kind of sub-optimal. Here's the two functions I'm using in case I'm missing something obvious:

    -- the function that grabs targets, registered to gmcp.Char.Items.List 
    function getHuntTargs ()
    targetList = {}
    for ih,vh in ipairs(gmcp.Char.Items.List.items) do
    for it, vt in ipairs(huntingTargs) do
    if gmcp.Char.Items.List.items[ih].name == vt then
    table.insert(targetList, gmcp.Char.Items.List.items[ih].id)
    end -- if
    end --for
    end --for
    end -- getHuntTargs

    -- the function that sends the current target to Achaea, registered to targetUpdate
    function achaeaTarget ()
    if targetList[1] then
    sendGMCP([[IRE.Target.Set "]]..targetList[1]..[["]])
    sendGMCP([[IRE.Target.Set ""]])
    end -- if
    end -- achaeaTarget
  • Hrm, I don't see anything obvious... But you are not guarding the "gethuntTargs" function against updates that are not in the room. The same event is also triggered for the list of inventory items as well as item lists in containers. If you are regularly retriving one of those lists, it'll overwrite your targetList. So the first thing you want to do in your getHuntTargs function is something akin to
    if gmcp.Char.Items.List.location ~= "room" then return

    Maybe that fixes part of your issue.

    And if you get tired of making your own or need inspiration, you can always have a look at </shameless plug>

  • Forgive the necromancy, but I couldn't let search result threads to a problem I shared go unanswered. I tangled with this challenge recently and found that my gmcp target messages were being truncated, losing the first and last digit. The solution to make targets select correctly was to escape the target id with quotation marks like so:

    sendGMCP("IRE.Target.Set \""..tid.."\"")

Sign In or Register to comment.