Help with a Targeting script

DemartelDemartel Member Posts: 441 Virtuoso
I am trying to make my target caller only call the room and area if the target is actually in the room. It doesn't work as hoped though.


target = string.title(matches[2])


local roomnum = gmcp.Room.Info.num

local roomname = gmcp.Room.Info.name

local roomarea = gmcp.Room.Info.area



for k,v in pairs(gmcp.Room.Players) do

if k == target then

mm.cc("Targeting: " .. target.." - I'm currently located at "..roomname.." in "..roomarea.." ("..roomnum..")", false)

else

mm.cc("Targeting: " .. target, false)

end -- if

end -- for

Comments

  • YarouYarou Member Posts: 218 Master
    It may help if you share what client / system you're using. I wish I could help, but from the looks of it, you're using .. Mudlet and .. maybe m&mf?

    If you are using Mudlet, I'd suggest going to Mudlet's forums and asking for help there. You might have a better chance of getting the advice you want more quickly there. Like I said, I wish I could help but I'm shit at Mudlet :( Best of luck!

  • TarkentonTarkenton Traitor Bear Member Posts: 2,555 Transcendent
    What does it do instead of what you want it to do?
    image
  • DemartelDemartel Member Posts: 441 Virtuoso
    It just defaulted to the not in room else statement.
    I got it working though. I just added a variable to the For statement and then checked that Variable for the actual callout.
    To be honest if it wasn't for @Tarkenton's gui I probably would not have figured it out. My work around is probably not the most elegant, but it works.

    for k,v in pairs(gmcp.Room.Players) do

    if target == gmcp.Room.Players[k].name then

    targetHere = true

    end -- end if

    end -- end for

    if targetHere == true then

    mm.cc("Targeting: " .. target.." - I'm currently located at "..roomname.." in "..roomarea.." ("..roomnum..")", false)

    else

    mm.cc("Targeting: " .. target, false)

    end -- if


  • FalaeronFalaeron Jolteon Member Posts: 1,663 Transcendent
    Try this

    target = string.title(matches[2])

    local roomnum = gmcp.Room.Info.num


    local roomname = gmcp.Room.Info.name


    local roomarea = gmcp.Room.Info.area


    local playerinroom = false


    for k,v in pairs(gmcp.Room.Players) do


    if v["name"] == target then

    playerinroom = true


    end -- if


    end -- for


    if playerinroom then

    mm.cc("Targeting: " .. target.." - I'm currently located at "..roomname.." in "..roomarea.." ("..roomnum..")", false)

    else

    mm.cc("Targeting: " .. target, false)

    end


  • TarkentonTarkenton Traitor Bear Member Posts: 2,555 Transcendent
    Yay, I helped indirectly!
    image
Sign In or Register to comment.