[Home] [Downloads] [Search] [Help/forum]


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, 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.
[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Plugins
. . -> [Subject]  Aardwolf GMCP plugin - partial refreshes of data

Aardwolf GMCP plugin - partial refreshes of data

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


Posted by Sickent   USA  (12 posts)  [Biography] bio
Date Sun 08 Jun 2014 04:36 PM (UTC)

Amended on Sun 08 Jun 2014 04:42 PM (UTC) by Sickent

Message
http://www.aardwolf.com/wiki/index.php/Clients/MushclientGMCP
http://www.aardwolf.com/gmcp/gmcp-plugin.zip

I've started using this plugin in my systems on IRE games. I've seen it suggested in other threads and it's worked so far. I couldn't find a forum post for FAQs and updates, so I'm asking here.

This plugin explains:
--
Purpose is to receive incoming GMCP messages and populate the global table 'gmcpdata' with the values as received so that GMCP under Mushclient can use partial refreshes of data. For example, we might receive:

char.vitals { "hp": 100000, "mana": 90000, "moves": 41599 }

Then next time, if only HP and Mana have changed, receive:

char.vitals { "hp": 100000, "mana": 85000 }

The previous value for 'moves' will be remembered and available until it is refreshed.
--

This is specifically bad with Aetolia and its Char.Afflictions and Char.Afflictions.list (I think they end up being the same thing). When you cure an affliction, the original global table isn't updating because it's not supposed to by design. I can't clear this table from local script, and I'm not really understanding how/when the plugin builds the original table.

In the above example, what I'd want:
--
We might receive from char.vitals:

char.vitals { "hp": 100000, "mana": 90000, "moves": 41599 }

Then next time receive:

char.vitals { "hp": 100000, "mana": 85000 }

The previous value vitals.moves is nil, as it was deleted when we received new information from char.vitals.
--

Any help would be appreciated. Thank you.
[Go to top] top

Posted by Nick Gammon   Australia  (23,045 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 08 Jun 2014 09:48 PM (UTC)

Amended on Sun 08 Jun 2014 09:49 PM (UTC) by Nick Gammon

Message
I can't reproduce that. If I install the GMCP_handler plugin, and then turn on debugging:


gmcpdebug 2


I then send a test packet (Ctrl+Shift+F12):


\FF\FA\C9char.vitals { "hp": 100000, "mana": 90000, "moves": 41599 }\FF\F0


I get the debug message:


gmcpdata serialized: {
  char = {
    vitals = {
      mana = "90000",
      hp = "100000",
      moves = "41599",
      },
    },
  }


Now if I send the second packet with no change to moves:


\FF\FA\C9char.vitals { "hp": 200000, "mana": 85000 }\FF\F0


The debug says:


char.vitals { "hp": 200000, "mana": 85000 }
gmcpdata serialized: {
  char = {
    vitals = {
      mana = "85000",
      hp = "200000",
      moves = "41599",
      },
    },
  }


So the moves are still there.

You will have to post your code and show what you are doing and what you are displaying. Just describing it doesn't let us help you.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Sickent   USA  (12 posts)  [Biography] bio
Date Reply #2 on Sun 08 Jun 2014 11:22 PM (UTC)
Message
I can't demonstrate the issue without showing what's incoming from the MU* _without_ the plugin, and the only tool I know that'll do that is Wireshark. And incoming from the MU* is spitting gibberish to me, with exception to the loggin.

So, the example I'd provide, you'd have to trust that I'm not talking out of my rump or that the game isn't behaving like it shouldn't.

Three seconds for the later, unless you know how to work Wireshark.
[Go to top] top

Posted by Nick Gammon   Australia  (23,045 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Mon 09 Jun 2014 03:45 AM (UTC)
Message
Sickent said:

And incoming from the MU* is spitting gibberish to me, with exception to the loggin.



Can you copy and paste this gibberish? I don't know what you are telling me here.

I made a new character on Aetolia and with gmcpdebug set to level 1, I see this every time the MUD sends something:


Char.Vitals { "hp": "343", "maxhp": "343", "mp": "357", "maxmp": "357", "ep": "615", "maxep": "615", "wp": "600", "maxwp": "600", "nl": "0", "xp": "0", "maxxp": "5001", "blood": "100", "bleeding": "0", "blind": "0", "deaf": "0", "prone": "1", "cloak": "0", "fangbarrier": "0", "flying": "0", "herb": "1", "salve": "1", "pipe": "1", "elixir": "1", "moss": "1", "tree": "1", "renew": "1", "affelixir": "1", "focus": "1", "soul": "100", "residual": "0", "madness": "0", "status": "living", "balance": "1", "equilibrium": "1", "left_arm": "1", "right_arm": "1", "wield_left": "", "wield_right": "", "class": "ascendril", "mounted": "0", "burrowed": "no", "string": "H:343/343 M:357/357 E:615/615 W:600/600 NL:0/100 " }
[][]


It doesn't look to me like it is sending a subset of the data. Also for you to use the plugin you need to have your own plugin that receives the data. So I'm not sure what you are trying to do, what you expect to happen, and what is actually happening.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,045 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Mon 09 Jun 2014 03:48 AM (UTC)
Message
Sickent said:

Three seconds for the later, unless you know how to work Wireshark.


MUSHclient has a packet debug mode (see the Edit menu). That tells you exactly what is arriving.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (23,045 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Mon 09 Jun 2014 05:31 AM (UTC)

Amended on Mon 09 Jun 2014 05:32 AM (UTC) by Nick Gammon

Message
This small plugin demonstrates how you might use GMCP. I tested it in Aetolia.

Template:saveplugin=GMCP_demo To save and install the GMCP_demo plugin do this:
  1. Copy between the lines below (to the Clipboard)
  2. Open a text editor (such as Notepad) and paste the plugin into it
  3. Save to disk on your PC, preferably in your plugins directory, as GMCP_demo.xml
  4. Go to the MUSHclient File menu -> Plugins
  5. Click "Add"
  6. Choose the file GMCP_demo.xml (which you just saved in step 3) as a plugin
  7. Click "Close"



<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="GMCP_demo"
   author="Nick Gammon"
   id="b9171e77bc4ed6d2926eebdc"
   language="Lua"
   purpose="GMCP demonstration"
   date_written="2014-06-09"
   requires="4.73"
   version="1.0"
>
</plugin>

<!--  Script  -->

<script>
<![CDATA[

fulldata = {}

--=================================================================================
-- Called when plugin receives telnet data - main entry point for actually running
-- the plugin.
--=================================================================================
function OnPluginBroadcast (msg, id, name, text)

   -- Look for GMCP handler.
   if (id == '3e7dedbe37e44942dd46d264') then
      if (text == 'reload') then
         -- invalidate current data
         fulldata = {} 
         return
      end
     -- print ("GMCP packet = ", text)
      if (text == "Char.Base" or text == "Char.Vitals" or text == "Char.Status" or text == "Char.Maxstats") then
         res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","Char")

         luastmt = "gmcpdata = " .. gmcparg
         assert (loadstring (luastmt or "")) ()

         -- copy into fulldata
         for k, v in pairs (gmcpdata) do
           fulldata [k] = v
         end -- for
      
      if text == "Char.Vitals" then
        ShowHealth ()
      end -- if
      end
   end
end

oldequilibrium = 0
oldbalance = 0

function ShowHealth ()
  hp          = tonumber (fulldata.Vitals.hp)
  maxhp       = tonumber (fulldata.Vitals.maxhp)
  equilibrium = tonumber (fulldata.Vitals.equilibrium)
  balance     = tonumber (fulldata.Vitals.balance)

  SetStatus ("Health: " .. hp .. "/" .. maxhp .. " Equilibrium = " .. equilibrium .. " Balance = " .. balance )
  
  if equilibrium == 1 and oldequilibrium == 0 then
    ColourNote ("darkgreen", "", "You have regained equilibrium")
  elseif equilibrium == 0 and oldequilibrium == 1 then
    ColourNote ("darkred", "", "You have lost equilibrium")
  end --if
  oldequilibrium = equilibrium
  
  if balance == 1 and oldbalance == 0 then
    ColourNote ("darkgreen", "", "You have regained balance")
  elseif balance == 0 and oldbalance == 1 then
    ColourNote ("darkred", "", "You have lost balance")
  end --if
  oldbalance = balance
  
end -- ShowHealth

]]>
</script>
</muclient>


This gets the stats from the GMCP data, and in the function ShowHealth updates the status bar with your hit points, and shows a message when you gain or lose equilibrium or balance.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Sickent   USA  (12 posts)  [Biography] bio
Date Reply #6 on Mon 09 Jun 2014 11:42 PM (UTC)

Amended on Wed 02 Jul 2014 01:51 AM (UTC) by Sickent

Message
Your plugin is easier to understand and I can do what I want from it. I don't need to make that example anymore.

Thank you for the base code. I'll copy here or in a pastebin what I'm doing with your example when I figure out how to use this new direction.
[Go to top] 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.


18,942 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]