[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.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Simple GMCP plugin

Simple GMCP plugin

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


Pages: 1  2  3  4 5  

Posted by Solara   USA  (59 posts)  Bio
Date Reply #45 on Sat 04 Oct 2014 08:15 PM (UTC)

Amended on Sat 04 Oct 2014 08:25 PM (UTC) by Solara

Message
Yeah extracted over all files from GMCP.plugin.zip and RoomName.plugin.zip.

Copy/pasted what you posted above for the revised main.lua in /plugins/RoomName.plugin/scripts.

Changed all my triggers to GetPluginVariable ("e94f6bd8509a2b00d10cb226".

My test alias should send all team member's info but it returns a message indicating T1_Name is nil.

It does pull the Char.Vitals info correctly though.
Top

Posted by Nick Gammon   Australia  (23,046 posts)  Bio   Forum Administrator
Date Reply #46 on Sat 04 Oct 2014 08:16 PM (UTC)
Message
Post your new setup if you want help with it. What is sending and what is receiving.

- Nick Gammon

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

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #47 on Sat 04 Oct 2014 08:18 PM (UTC)
Message
In no particular order, try these things:

* Make sure the original Aardwolf GMCP plugin is not loaded in MUSHclient.

* Use the GMCP DEBUG alias to enable/disable GMCP output.

* Add print("Hello!") to ShowHealthTeam to make sure it's getting called at all.

* Restart MUSHclient.

'Soludra' on Achaea

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #48 on Sat 04 Oct 2014 08:39 PM (UTC)

Amended on Sat 04 Oct 2014 08:40 PM (UTC) by Solara

Message
Only GMCP plugin and RoomInfo plugins are active. Reloaded Mushclient, added this line to RoomInfo's main.lua:

local PPI = require("ppi")

local function ShowHealth(message, Vitals)
  SetVariable("HP_gmcp", Vitals.hp)
  SetVariable("Mana_gmcp", Vitals.mana)
  SetVariable("Fatigue_gmcp", Vitals.fatigue)
  SetVariable("Bleeding_gmcp", Vitals.bleeding)
end

local function ShowHealthTeam(message, Team)
print ("hello!")
  for x=1,8 do
    if Team[x] then
      SetVariable("T"..x.."_Name", Team[x].name)
      SetVariable("T"..x.."_HP", Team[x].hp)
      SetVariable("T"..x.."_Blood", Team[x].blood)

      if Team[x].pos == "0" then
        SetVariable("T"..x.."_Pos", "Front")
      else
        SetVariable("T"..x.."_Pos", "Back")
      end
    else
      DeleteVariable("T"..x.."_Name")
      DeleteVariable("T"..x.."_HP")
      DeleteVariable("T"..x.."_Blood")
      DeleteVariable("T"..x.."_Pos")
    end
  end
end

-- (ID, on_success, on_failure)
PPI.OnLoad("29a4c0721bef6ae11c3e9a82", function(gmcp)
  gmcp.Listen("Char.Vitals", ShowHealth)
  gmcp.Listen("Room.Info", ShowHealthTeam)
end, function(reason)
  -- Do nothing if GMCP.plugin is not present.
end)

function OnPluginListChanged()
  PPI.Refresh()
end


Does NOT print "hello!". gmcpdebug still shows incoming data with both char.vitals and char.team.

My scripts to show char.vitals to a miniwindow are still working. Does not show any char.team data.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #49 on Sat 04 Oct 2014 08:40 PM (UTC)
Message
Ahh, my fault. I see the problem.

gmcp.Listen("Room.Info", ShowHealthTeam)

Do you?

'Soludra' on Achaea

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #50 on Sat 04 Oct 2014 08:43 PM (UTC)
Message
Interesting enough, when I force someone to leave the team, or they rejoin, then the script kicks in and sends the "hello!" - but data is still nil for char.team variables.

The mud DOES send data every few secs and after every command that gets sent to the mud so it's rather weird that this plugin only seems to kick in when someone joins or leaves the team?
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #51 on Sat 04 Oct 2014 08:45 PM (UTC)
Message
Haha, yeah that was the problem. I didn't lok very carefully there. Thanks!
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #52 on Sat 04 Oct 2014 08:49 PM (UTC)
Message
Okay well, we're back to the original problem with the aardwolf plugin again. Does NOT seem that the char.team data gets updated either for this one.

With the aardwolf plugin, if I sent a ReloadPlugin command for the GMCP_Demo plugin (not the GMCP_Handler), then it gets updated.

Very bizarre because this plugin should delete/nil out the variables - and my script pulls the variables directly from the plugins - i do not set any global variables that I'm forgetting to update by mistake.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #53 on Sat 04 Oct 2014 08:50 PM (UTC)
Message
I'd like to take a look at this myself. What MUD are you developing against?

'Soludra' on Achaea

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #54 on Sat 04 Oct 2014 08:55 PM (UTC)
Message
Well I might just have to live with this quirk, unless someone can figure it out - may need to put in some Reloadplugin commands for some triggers.

Updated main.lua for RoomInfo.plugin

local PPI = require("ppi")

local function ShowHealth(message, Vitals)
  SetVariable("HP_gmcp", Vitals.hp)
  SetVariable("Mana_gmcp", Vitals.mana)
  SetVariable("Fatigue_gmcp", Vitals.fatigue)
  SetVariable("Bleeding_gmcp", Vitals.bleeding)
end

local function ShowHealthTeam(message, Team)
  for x=1,8 do
    if Team[x] then
      SetVariable("T"..x.."_Name", Team[x].name)
      SetVariable("T"..x.."_HP", Team[x].hp)
      SetVariable("T"..x.."_Blood", Team[x].blood)

      if Team[x].pos == "0" then
        SetVariable("T"..x.."_Pos", "Front")
      else
        SetVariable("T"..x.."_Pos", "Back")
      end
    else
      DeleteVariable("T"..x.."_Name")
      DeleteVariable("T"..x.."_HP")
      DeleteVariable("T"..x.."_Blood")
      DeleteVariable("T"..x.."_Pos")
    end
  end
end

-- (ID, on_success, on_failure)
PPI.OnLoad("29a4c0721bef6ae11c3e9a82", function(gmcp)
  gmcp.Listen("Char.Vitals", ShowHealth)
  gmcp.Listen("Char.Team", ShowHealthTeam)
end, function(reason)
  -- Do nothing if GMCP.plugin is not present.
end)

function OnPluginListChanged()
  PPI.Refresh()
end



Most recent GMCP_Demo.xml using Aardwolf GMPC_Handler.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>

<muclient>
<plugin
   name="Xyllo_Vitals"
   author="LP, modified from Nick Gammon"
   id="b9171e77bc4ed6d2926eebdc"
   language="Lua"
   purpose="GMCP Vitals for Xyllomer"
   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.Vitals" or text == "Char.Team") 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
      if text == "Char.Team" then
        ShowHealthTeam ()
      end -- if
      end
   end
end


function ShowHealth ()

  SetVariable ("HP_gmcp", fulldata.Vitals.hp)
  SetVariable ("Mana_gmcp", fulldata.Vitals.mana)
  SetVariable ("Fatigue_gmcp", fulldata.Vitals.fatigue)
  SetVariable ("Bleeding_gmcp", fulldata.Vitals.bleeding)

end -- ShowHealth

function ShowHealthTeam ()

for x=1,8 do

if fulldata.Team[x] ~= nil then
  SetVariable ("T"..x.."_Name", fulldata.Team[x].name)
  SetVariable ("T"..x.."_HP", fulldata.Team[x].hp)
  SetVariable ("T"..x.."_Blood", fulldata.Team[x].blood)

  if fulldata.Team[x].pos == "0" then SetVariable ("T"..x.."_Pos", "Front")
  else SetVariable ("T"..x.."_Pos", "Back")
  end

end -- if
end -- loop
end -- ShowHealthTeam


]]>
</script>
</muclient>
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #55 on Sat 04 Oct 2014 08:57 PM (UTC)
Message
Twisol said:

I'd like to take a look at this myself. What MUD are you developing against?


Xyllomer.mud.de.3000
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #56 on Sat 04 Oct 2014 09:05 PM (UTC)

Amended on Sat 04 Oct 2014 09:07 PM (UTC) by Twisol

Message
While I wait for my password, could you export the aliases/triggers you're using to access the plugin's variables and paste them here?

[EDIT]: Just FYI, you can go to the Edit -> Convert Clipboard Forum Codes menu in MUSHclient to convert any [i]-like things that you've copied to \[i].

'Soludra' on Achaea

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #57 on Sat 04 Oct 2014 09:39 PM (UTC)
Message
This is the main miniwindow script where I display the plugin variables. This action gets executed by several triggers.

WindowDelete ("battle")
win = "battle" .. GetPluginID ()
WindowCreate (win, 0, 0, 180, 210, miniwin.pos_bottom_right, 0, ColourNameToRGB("blue"))
WindowShow (win,  true)

WindowFont (win, "f", "Trebuchet MS", 12, true, false, true, false)
WindowFont (win, "f1", "Trebuchet MS", 12, true, false, false, false)
WindowText (win, "f", "Battle Status", 45, 5, 0, 0, ColourNameToRGB ("yellow"), false)

WindowText (win, "f1", "Weap:  "..GetVariable("bweapon"), 10, 35, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", "HP:  "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "HP_gmcp")..", "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "Bleeding_gmcp"), 10, 55, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", "Mana:  "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "Mana_gmcp"), 10, 75, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", "Fatigue:  "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "Fatigue_gmcp"), 10, 95, 0, 0, ColourNameToRGB ("yellow"), false)

if GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Name") == nil then
WindowText (win, "f1", "-NOT TEAMED-", 10, 125, 0, 0, ColourNameToRGB ("white"), false)
end

if GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Name") == "Pringle" then
WindowText (win, "f1", GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Name")..": "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_HP")..", "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Blood"), 10, 118, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Name")..": "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Pos"), 10, 138, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", "Me:  "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Pos"), 10, 158, 0, 0, ColourNameToRGB ("yellow"), false)

elseif GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Name") == "Pringle" then
WindowText (win, "f1", GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Name")..": "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_HP")..", "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Blood"), 10, 118, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Name")..": "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Pos"), 10, 138, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", "Me:  "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Pos"), 10, 158, 0, 0, ColourNameToRGB ("yellow"), false)

elseif GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T3_Name") == "Pringle" then
WindowText (win, "f1", GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Name")..": "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_HP")..", "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Blood"), 10, 118, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Name")..": "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_HP")..", "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Blood"), 10, 138, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", "Me:  "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T3_Pos"), 10, 158, 0, 0, ColourNameToRGB ("yellow"), false)

elseif GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T4_Name") == "Pringle" then
WindowText (win, "f1", GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Name")..": "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_HP")..", "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Blood"), 10, 118, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Name")..": "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_HP")..", "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T2_Blood"), 10, 138, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T3_Name")..": "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T3_HP")..", "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T3_Blood"), 10, 138, 0, 0, ColourNameToRGB ("yellow"), false)
WindowText (win, "f1", "Me:  "..GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T4_Pos"), 10, 158, 0, 0, ColourNameToRGB ("yellow"), false)

else
end
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #58 on Sat 04 Oct 2014 09:39 PM (UTC)

Amended on Sat 04 Oct 2014 09:42 PM (UTC) by Solara

Message
This is just a testing script to let me know if the variables are there or not:

for i=1,8 do
if GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T"..i.."_Name") ~= nil then
TiName = GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T"..i.."_Name")
TiHP = GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T"..i.."_HP")
TiBlood = GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T"..i.."_Blood")
TiPos = GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T"..i.."_Pos")

Note (i.."- "..TiName.." | "..TiPos.." | Health: "..TiHP.." | Blood: "..TiBlood)

end -- if
end -- loop

if GetPluginVariable ("b9171e77bc4ed6d2926eebdc", "T1_Name") == nil then
Note ("Not Teamed")
end


Now the mud does have known problems with it's GMCP data - small mud with not many active admins, so not sure if it'll ever get fixed.

1st quirk - depending on who's in the team all team members will have -1HP listed (seems to occur when wolves/elementals are in team only).

Now when I said earlier that the ReloadPlugin command seemed to fix/update the char.team correctly - that is true for most situations, but when an elemental/wolf is put into the team, when they leave the team, it doesn't look like the char.team is updated ever even after disbanding the team - it shows phantom 3rd teamemember - quirk of gmcp from mud likely then). What's weird is (went back to using aardwolf plugin for testing - it shows only 2 team members when using debug 1, but shows 3 when using debug 2. Anyways, not sure anyone could figure any of this out with a not-completely bug-free mud gmcp data stream.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #59 on Sat 04 Oct 2014 09:40 PM (UTC)
Message
Unless you changed the ID of RoomName.plugin in its XML file, you need to change "b9171e77bc4ed6d2926eebdc" to "e94f6bd8509a2b00d10cb226".

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
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.


144,351 views.

This is page 4, subject is 5 pages long:  [Previous page]  1  2  3  4 5  [Next page]

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

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]