[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 #60 on Sat 04 Oct 2014 10:10 PM (UTC)
Message
Twisol said:

Unless you changed the ID of RoomName.plugin in its XML file, you need to change "b9171e77bc4ed6d2926eebdc" to "e94f6bd8509a2b00d10cb226".


Oh I had gone back to aardwolf plugins to do some testing when I pasted those codes - have 2 separate game files for each plugin.

And an update - seems it's not just wolf/elemental, but even other players - the char.team is NOT updated even after using the ReloadPlugin. The ReloadPlugin command seemed to help when it was just 2 people in the team, but 3 or more I think it doesn't help. So the problem is likely on the MUD side??
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #61 on Sat 04 Oct 2014 10:13 PM (UTC)
Message
What do you see when GMCP DEBUG is active? Does the output make sense, or does it also exhibit the same issue?

'Soludra' on Achaea

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

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

Amended on Sat 04 Oct 2014 11:03 PM (UTC) by Solara

Message
Okay so I went back to using your plugin Twisol and now everything seems to be updating fine!

Switched between the two plugins several times and aardwolf consistently does NOT update char.team but yours does.

But there are problems for both plugins when it comes to elementals/wolves being in the team. With aardwolf plugin, when they enter the team, all HP for team members is shown as -1HP. The non-updating of the char.team does not depend on who is in the team.

With your plugin Twisol, I get the following message with elemental/wolf in the team:

Run-time error
Plugin: XylloVitals (called from world: Xyllomer)
Function/Sub: PPI_INVOKE called by Plugin XylloVitals
Reason: Executing plugin XylloVitals sub PPI_INVOKE
...ient\worlds\plugins\RoomName.plugin\scripts\main.lua:13: bad argument #2 to 'SetVariable' (string expected, got nil)
stack traceback:
        [C]: in function 'SetVariable'
        ...ient\worlds\plugins\RoomName.plugin\scripts\main.lua:13: in function 'func'
        ...ent\worlds\plugins\RoomName.plugin\libraries\ppi.lua:379: in function <...ent\worlds\plugins\RoomName.plugin\libraries\ppi.lua:362>


Here's the full debug when elementals enter the team for Twisol's plugin:

"message"="Char.Vitals"
"data":
  "fatigue"=0
  "mana"=100
  "hp"=100
  "bleeding"=0

"message"="Char.Team"
"data":
  1:
    "name"="Kami"
    "pos"="0"
    "leader"="0"
    "hp"="100"
    "blood"="0"
  2:
    "name"="An earth elemental"
    "pos"="0"
    "leader"="0"
    "hp"="100"
    "blood"="0"
  3:
    "name"="Pringle"
    "pos"="1"
    "leader"="1"
    "hp"="100"
    "blood"="0"

"message"="Char.Team"
"data":
  1:
    "pos"="0"
    "leader"="0"
    "hp"="-1"
    "blood"="0"
  2:
    "pos"="0"
    "leader"="0"
    "hp"="-1"
    "blood"="0"
  3:
    "pos"="1"
    "leader"="1"
    "hp"="-1"
    "blood"="0"


The mud seems to send two batches of char.team data - first one is correct, second one has -1 for HP and name appears to be nil on the second batch. So with aardwolf's plugin because old char.team.name is not wiped, it still allows my script to run and shows -1HP for each. With Twisol's more dynamic plugin, since name is now 'nil', it errors out - though I'm not sure why since the routine to set variables is checking for nil.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #63 on Sat 04 Oct 2014 10:51 PM (UTC)
Message
So the MUD expects you to remember at least some details about the team, such as the team members' names, so it doesn't have to repeat itself.

Assuming the 'name' field is the only one that behaves this way, change this line:
SetVariable("T"..i.."_Name", Team[i].name)
to this:
if Team[i].name then
  SetVariable("T"..i.."_Name", Team[i].name)
end

'Soludra' on Achaea

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

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #64 on Sat 04 Oct 2014 10:55 PM (UTC)

Amended on Sat 04 Oct 2014 10:57 PM (UTC) by Twisol

Message
And since 'hp' is inexplicably -1, do a similar thing here:
if Team[i].hp ~= "-1" then
  SetVariable("T"..i.."_HP", Team[i].hp)
end

You probably see the pattern. At this point, we're just dealing with the idiosyncrasies of the MUD, rather than any actual bugs in the plugins.

'Soludra' on Achaea

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #65 on Sat 04 Oct 2014 11:12 PM (UTC)

Amended on Sat 04 Oct 2014 11:15 PM (UTC) by Solara

Message
Yeah we're pretty much dealing with a MUD error now. Plugin works great otherwise except for that specific situation.

Now changing main.lua to this, I only ever get char.vitals and NO char.team ever gets set to variables I can pull.

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.."_Blood", Team[x].blood)

      if Team[x].name then
        SetVariable("T"..x.."_HP", Team[x].name)
      end
      
      if Team[x].hp ~= "-1" then
        SetVariable("T"..x.."_HP", Team[x].hp)
      end

      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


Okay noticed my typing error after I posted. Works now!

if Team[x].name then
        SetVariable("T"..x.."_HP", Team[x].name)
      end


should be:

if Team[x].name then
        SetVariable("T"..x.."_Name", Team[x].name)
      end
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #66 on Sat 04 Oct 2014 11:16 PM (UTC)

Amended on Sat 04 Oct 2014 11:18 PM (UTC) by Twisol

Message
[EDIT]: Ah, that would do it. Ignore the below.

Use tprint to print out the data that you're working with in the loop. Put this before the loop inside ShowHealthTeam.
local tprint = require("tprint")
tprint(Team)

'Soludra' on Achaea

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #67 on Sat 04 Oct 2014 11:29 PM (UTC)

Amended on Sat 04 Oct 2014 11:30 PM (UTC) by Solara

Message
Thanks for all your help Twisol, works very nicely now.

A minor cosmetic question for the miniwindows so the words can fit better. How do I query the TName variable I just set in the plugin to screen for any anmes with 'elemental' in it, and then reassign it so it does not contain the 'elemental' word?

I tried with this command but it doesn't seem to work?

      if Team[x].name then
        SetVariable("T"..x.."_Name", Team[x].name)
        string.gsub ("T"..x.."_Name", "elemental", "")
      end
Top

Posted by Solara   USA  (59 posts)  Bio
Date Reply #68 on Sat 04 Oct 2014 11:34 PM (UTC)
Message
Changed to this but still not working.

      if Team[x].name then
        SetVariable("T"..x.."_Name", Team[x].name)
        string.gsub (GetVariable("T"..x.."_Name"), "elemental", "")
      end
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #69 on Sat 04 Oct 2014 11:34 PM (UTC)
Message
You can't very well change an e-mail you've already sent. Put the gsub call before the SetVariable call.

'Soludra' on Achaea

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #70 on Sun 05 Oct 2014 12:35 AM (UTC)
Message
I'm probably not understanding, but this didn't seem to work either. No errors in script though and everything still works, just no truncation of any elemental team names.

      if Team[x].name then
        string.gsub (Team[x].name, "elemental", "")
        SetVariable("T"..x.."_Name", Team[x].name)
      end


tried this variation also:

      if Team[x].name then
        if string.find (Team[x].name, "elemental") then
          string.gsub (Team[x].name, "elemental", "")
        end
        SetVariable("T"..x.."_Name", Team[x].name)
      end


Not sure if Team[x] is considered a string or not. And if not, I'd have to set it to a variable first before substituting it - which is what I did with my original attempt?
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #71 on Sun 05 Oct 2014 12:40 AM (UTC)

Amended on Sun 05 Oct 2014 12:43 AM (UTC) by Twisol

Message
In Lua, functions cannot modify their parameters unless they are tables. Copies are made instead. Since strings aren't tables, the only way gsub could do its job is to have its result be its return value.

I'm being coy because this, in particular, is fundamental. You should understand what's happening, not merely be told about it.

There's no shame in asking once more if you still don't understand. :)

[EDIT]: I will point out, though, that Team, Team[i], and Team[i].name all give different values. The first and second give tables, though the first is treated as an array. The third gives a string.

'Soludra' on Achaea

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

Posted by Solara   USA  (59 posts)  Bio
Date Reply #72 on Sun 05 Oct 2014 12:54 AM (UTC)
Message
Haha such a dumb mistake. Works now.

      if Team[x].name then
        Team[x].name = string.gsub(Team[x].name, "elemental", "")
        SetVariable("T"..x.."_Name", Team[x].name)
      end
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,349 views.

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

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]