Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ get unique room id from mccp

get unique room id from mccp

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Shwick   (21 posts)  Bio
Date Tue 25 May 2010 02:31 PM (UTC)

Amended on Tue 25 May 2010 07:52 PM (UTC) by Shwick

Message
In aardwolf, I know the underlying mccp protocol contains a unique room id for each room you visit. For example,

RoomEnvironment: aylorcity
RoomNum: 32418
RoomFullExits: n(32539), e(32698), s(32419), w(30518), u(35200), d(32615)

Is there a function that can access the RoomNum and RoomFullExits, or how would I go about doing that.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 25 May 2010 08:33 PM (UTC)

Amended on Tue 25 May 2010 08:34 PM (UTC) by Nick Gammon

Message
It is the ATCP protocol (using telnet subnegotiation), not MCCP which is data compression.

First, grab the ATCP_NJG plugin from here

http://github.com/nickgammon/plugins/blob/master/ATCP_NJG.xml

My mapper module can be downloaded from here:

http://github.com/nickgammon/mushclient/blob/master/lua/mapper.lua

My mapper plugin (which works with Aardwolf) can be downloaded from here:

http://github.com/nickgammon/plugins/blob/master/ATCP_Mapper.xml

You don't need the mapper module or mapper plugin, however they show how you can interact with the ATCP stuff to grab the room numbers.

Basically the important stuff is here, if you want do write your own:


handlers = {
  [1] = got_vitals,             -- eg. "H:496/496 M:412/412 E:1380/1380 W:960/960 NL:89/100"
                                --      health    mana      endurance   willpower experience
  [2] = got_room_name,          -- eg. "Continuing on the Parade of Zarathustra"
  [3] = got_room_exit,          -- eg. "n,s"
  [4] = got_room_number,        -- eg. "401"
  [5] = got_room_full_exits,    -- eg. "ne(8564),w(8428)"
  [6] = got_environment,        -- eg. "Urban"
  [7] = got_coordinates,        -- eg. "38,3,1,0"
  [8] = got_info,               -- eg. "shops,postoffice"
  }
  
function OnPluginBroadcast (msg, id, name, text)
  if id == "85f72d0e263d75df7bde6f00" then
  
    local f = handlers [msg]
    
    if f then
      f (text)
    end -- have handler
 
  end -- if ATCP message
end


The Atcp_NJG module basically detects the various types of messages in the telnet subnegotiation stream, and does a BroadcastPlugin of a different "id" number for each one. The code above simply detects that, and calls a handler (from the table above) to handle each different case. You would need to write your own handlers, the plugin I linked to shows the sort of thing you could do.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shwick   (21 posts)  Bio
Date Reply #2 on Tue 25 May 2010 11:17 PM (UTC)

Amended on Wed 26 May 2010 12:09 AM (UTC) by Shwick

Message
I can't get my test function to work.

I upgraded from mushclient 4.33 to 4.51, added the Atcp_NJG plugin and made sure it was enabled.

In my python scripts file I added a function,


def OnPluginBroadcast (msg, id, name, text):
    global test
    test = "IT WORKS"
    world.Note ("msg: " + msg)
    if id == "85f72d0e263d75df7bde6f00":
        if msg == 4:
            world.Note("4")
        elif msg == 5:
            world.Note("5")
        world.Note("text: " + text)


I never saw "msg: " printed, and the function that printed the test var never printed "IT WORKS". It seems like OnPluginBroadcast isn't being called.

I also tried a quick lua script, same thing no result


function OnPluginBroadcast (msg, id, name, text)
  world.Note("works")


I try to trigger OnPluginBroadcast by just moving to different rooms.

Also, OnPluginBroadcast doesn't depend on triggers at all, it's just called by the Atcp_NJG plugin? I tried it with triggers enabled/disabled.


I also noticed something with 4.51; I have one trigger ".*" that catches everything, and I do regex work in the scripts file.

The map tags seem to now be a hidden output in the main window, even though they are displayed in the Map window. My ".*" trigger, triggers much more often.

Also I keep getting a {stats} line too.

It could be my settings cause I upgraded mushclient.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 26 May 2010 12:01 AM (UTC)
Message
Using version 4.51, I installed just two plugins. The ATCP_NJG plugin I mentioned and this test one:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Wednesday, May 26, 2010, 9:58 AM -->
<!-- MuClient version 4.51 -->

<!-- Plugin "ATCP_Test" generated by Plugin Wizard -->

<muclient>
<plugin
   name="ATCP_Test"
   author="Nick Gammon"
   id="cee16d1d4f3c5f6681438fc2"
   language="Lua"
   purpose="Catches OnPluginBroadcast messages"
   date_written="2010-05-26 09:57:47"
   requires="4.51"
   version="1.0"
   >

</plugin>


<!--  Script  -->


<script>
<![CDATA[
function OnPluginBroadcast (msg, id, name, text)
  print ("OnPluginBroadcast called, got", msg, id, name, text)
end -- function
]]>
</script>


</muclient>


I logged into Aardwolf and moved around and saw this:


OnPluginBroadcast called, got 4 85f72d0e263d75df7bde6f00 ATCP_NJG 30608
OnPluginBroadcast called, got 2 85f72d0e263d75df7bde6f00 ATCP_NJG The Shores of Verume
OnPluginBroadcast called, got 7 85f72d0e263d75df7bde6f00 ATCP_NJG verume,0,0,0
OnPluginBroadcast called, got 6 85f72d0e263d75df7bde6f00 ATCP_NJG ocean
OnPluginBroadcast called, got 5 85f72d0e263d75df7bde6f00 ATCP_NJG n(30607),e(30612),s(30609),w(30601)


So it seems to work. You may need to log out and log back in to trigger the telnet negotiation. It may not detect it if you don't have the ATCP_NJG plugin installed at login time.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shwick   (21 posts)  Bio
Date Reply #4 on Wed 26 May 2010 12:13 AM (UTC)
Message
Ok that works for me now.

Problem was I wasn't exporting as a plugin.

Thanks this looks like it will help me a lot.
Top

Posted by Shwick   (21 posts)  Bio
Date Reply #5 on Thu 27 May 2010 07:40 PM (UTC)

Amended on Thu 27 May 2010 07:42 PM (UTC) by Shwick

Message
I keep getting a "type mismatch" error when I replicate that function in python.

Before I just copied your plugin and it worked, but that plugin is using lua.

Now that I'm using python,


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, May 27, 2010, 3:33 PM -->
<!-- MuClient version 4.51 -->

<!-- Plugin "pluginBroadcast" generated by Plugin Wizard -->

<muclient>
<plugin
   name="pluginBroadcast"
   id="fc96c4b049a3ad06f5f232d5"
   language="Python"
   date_written="2010-05-27 15:33:14"
   requires="4.51"
   version="1.0"
   >

</plugin>


<!--  Script  -->


<script>
<![CDATA[
def OnPluginBroadcast (msg, id, name, text):
    print ("OnPluginBroadcast called, got", msg, id, name, text)
    
]]>
</script>


</muclient>


I get the type mismatch whenever OnPluginBroadcast is triggered.

Also tried changing the print statement to pass, no luck.

Is it possible to do this in python?

Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #6 on Thu 27 May 2010 08:56 PM (UTC)
Message
You need an explicit "return 0" in Python for the plugin callbacks.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Shwick   (21 posts)  Bio
Date Reply #7 on Thu 27 May 2010 09:34 PM (UTC)

Amended on Fri 28 May 2010 05:17 PM (UTC) by Shwick

Message
omg twisol ty

thought i was gonna have to switch to lua again

damn you're only 17? you sound like some old professional on your webpage
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


21,574 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.