GMCP on Aardwolf

Posted by Quit on Sat 04 Apr 2015 12:11 PM — 13 posts, 52,783 views.

#0
Hi

I play on Aardwolf and I have used Cmud/Zmud for as long I can remember.

Now I have installed the Aardwolf MUSHclient Package from http://www.aardwolf.com/downloads/Aardwolf-Mud-MUSHclientr1802.zip and all is working.

Of all the things I want to do I need my level and tier level,
but I can't find out how to do it, I have read this http://www.aardwolf.com/wiki/index.php/Clients/MushclientGMCP
But that seems very complex for just getting my level from gmcp.

Can someone please show me how to get my level from gmcp and put it in a variable
USA #1
To do it with gmcp, you'll have to match on packet info which can be interesting but the gmcp link seems to have all the info you'll need to work with.
Amended on Sat 04 Apr 2015 06:50 PM by Meerclar
#2
<aliases>
  <alias
   match="test"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="100"
  >
  <send>require "gmcphelper"

Note (gmcpval("status.level"))</send>
  </alias>
</aliases>


gives me this error:
Run-time error
World: Aardwolf
Immediate execution
F:\MUSHclient\lua\gmcphelper.lua:18: nil parent passed to get_gmcp
stack traceback:
        [C]: in function 'assert'
        F:\MUSHclient\lua\gmcphelper.lua:18: in function 'get_gmcp'
        F:\MUSHclient\lua\gmcphelper.lua:76: in function <F:\MUSHclient\lua\gmcphelper.lua:75>
        (tail call): ?
        [string "Alias: "]:3: in main chunk


and I don't get this line:
(Note: the following code assumes you've already done the CallPlugin/loadstring dance above to populate the gmcpdata table)

from http://www.aardwolf.com/wiki/index.php/Clients/MushclientGMCP
USA Global Moderator #3
The gmcpval helper function requires you to first populate a variable called gmcpdata as shown in the section on that page where it shows
function OnPluginBroadcast (msg, id, name, text)
.

To test the data you want, do

res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char.status.level")
loadstring("gmcpdata = " .. gmcparg)

print("My level is "..gmcpdata)
#4
its give me this error:
Run-time error
World: Aardwolf
Immediate execution
[string "Alias: "]:4: attempt to concatenate global 'gmcpdata' (a table value)
stack traceback:
        [string "Alias: "]:4: in main chunk


But I got this to work:
res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char.status.level")
loadstring("gmcpdata = " .. gmcparg)

print("My level is "..gmcparg)


But I was hoping for something like this:
res, gmcparg = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char")
loadstring("gmcpdata = " .. gmcparg)

print("My Level is "..gmcparg("status.level"))
print("My Tier is "..gmcparg("base.tier"))


but this give this error:
Run-time error
World: Aardwolf
Immediate execution
[string "Alias: "]:4: attempt to call global 'gmcparg' (a string value)
stack traceback:
        [string "Alias: "]:4: in main chunk
Amended on Mon 06 Apr 2015 06:14 PM by Quit
Australia Forum Administrator #5

res, val = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char.vitals.hp")
print (val)   -- prints HP

res, val = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char.status.level")
print (val)   -- prints level
Australia Forum Administrator #6
You could make a helper function:


function getStats (what)
  result, value = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval", what)
  if result ~= 0 then
    ColourNote ("orange", "", "Warning: Could not get stats for " .. what)
    return nil
  end -- if
  return value
end -- getStats

print ("hp",    getStats ("char.vitals.hp"))
print ("mana",  getStats ("char.vitals.mana"))
print ("moves", getStats ("char.vitals.moves"))
print ("level", getStats ("char.status.level"))
print ("str",   getStats ("char.stats.str"))


Some appropriate stat types: GMCP in Aardwolf MUD
Amended on Tue 07 Apr 2015 12:41 AM by Nick Gammon
Australia Forum Administrator #7
I ran that in the Aardwolf client without making any other changes. In other words, that alone should do it.
Australia Forum Administrator #8
I should point out these values are strings (not numbers) so you should call "tonumber" if you want to manipulate them as numbers. eg.


if tonumber (getStats ("char.vitals.hp")) < 100 then
  print ("Health low")
end -- if


You can also get the entire group of stats, like this:


print (getStats ("char.base"))


This would print something like:


{
  class = "Warrior",
  race = "Troll",
  clan = "",
  subclass = "Barbarian",
  perlevel = "1000",
  tier = "0",
  remorts = "1",
  redos = "0",
  name = "Adrirabaen",
  pretitle = "",
  }


Now you can turn that into a table like Fiendish suggested, like this:


assert (loadstring ("charbase = " .. getStats ("char.base"))) () 

require "tprint"
tprint (charbase)


The first line turns that string into a table. The other two lines print it, like this:


"tier"="0"
"race"="Troll"
"clan"=""
"subclass"="Barbarian"
"pretitle"=""
"class"="Warrior"
"remorts"="1"
"perlevel"="1000"
"name"="Adrirabaen"
"redos"="0"


Now you can access individual items, eg.


print (charbase.name)  --> Adrirabaen
Amended on Tue 07 Apr 2015 07:38 AM by Nick Gammon
Australia Forum Administrator #9
Ditto for "char.status":


"level"="1"
"pos"="Standing"
"thirst"="90"
"hunger"="90"
"state"="3"
"tnl"="850"
"enemy"=""
"align"="0"


And so on for things like:

  • char.base
  • char.vitals
  • char.stats
  • char.maxstats
  • char.status
  • char.worth


Or get carried away and get everything:


assert (loadstring ("charbase = " .. getStats ("char"))) () 

require "tprint"
tprint (charbase)


Or getStats ("room"):


"info":
  "coord":
    "y"="20"
    "x"="30"
    "cont"="0"
    "id"="0"
  "num"="32520"
  "exits":
    "w"="32521"
    "s"="32535"
    "n"="32519"
  "details"=""
  "terrain"="road_crossroads"
  "name"="Whitewind Avenue at the corner of Faeriefog Lane"
  "zone"="aylor"


Note: The room info may not exist until you have moved at least once.
Amended on Tue 07 Apr 2015 01:17 AM by Nick Gammon
#10
Thank you for all your reply's, they help me alot

function getStats (what)
  result, value = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval", what)
  if result ~= 0 then
    ColourNote ("orange", "", "Warning: Could not get stats for " .. what)
    return nil
  end -- if
  return value
end -- getStats
--print (getStats("char.status.level"))

Send ("mobdeath " .. tonumber(getStats("char.status.level"))+10 .. " "..tonumber(getStats("char.status.level"))+30)
Amended on Wed 17 Jun 2015 06:47 PM by Quit
USA Global Moderator #11
Nick Gammon said:

You could make a helper function:


function getStats (what)
  result, value = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval", what)
  if result ~= 0 then
    ColourNote ("orange", "", "Warning: Could not get stats for " .. what)
    return nil
  end -- if
  return value
end -- getStats

print ("hp",    getStats ("char.vitals.hp"))
print ("mana",  getStats ("char.vitals.mana"))
print ("moves", getStats ("char.vitals.moves"))
print ("level", getStats ("char.status.level"))
print ("str",   getStats ("char.stats.str"))


Some appropriate stat types: GMCP in Aardwolf MUD


You could do that, but if you're constantly checking nested values you could just request char once and then index appropriately into the returned table.
Australia Forum Administrator #12
That would certainly be more efficient.