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

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  GMCP on Aardwolf
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

GMCP on Aardwolf

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


Posted by Quit   (12 posts)  [Biography] bio
Date Sat 04 Apr 2015 12:11 PM (UTC)
Message
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
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #1 on Sat 04 Apr 2015 06:46 PM (UTC)

Amended on Sat 04 Apr 2015 06:50 PM (UTC) by Meerclar

Message
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.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Quit   (12 posts)  [Biography] bio
Date Reply #2 on Sat 04 Apr 2015 08:47 PM (UTC)
Message
<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
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #3 on Mon 06 Apr 2015 12:03 AM (UTC)
Message
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)

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Quit   (12 posts)  [Biography] bio
Date Reply #4 on Mon 06 Apr 2015 06:13 PM (UTC)

Amended on Mon 06 Apr 2015 06:14 PM (UTC) by Quit

Message
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
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Mon 06 Apr 2015 10:11 PM (UTC)
Message

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

res, val = CallPlugin("3e7dedbe37e44942dd46d264","gmcpval","char.status.level")
print (val)   -- prints level

- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Tue 07 Apr 2015 12:36 AM (UTC)

Amended on Tue 07 Apr 2015 12:41 AM (UTC) by Nick Gammon

Message
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

- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Tue 07 Apr 2015 12:46 AM (UTC)
Message
I ran that in the Aardwolf client without making any other changes. In other words, that alone should do it.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Tue 07 Apr 2015 01:10 AM (UTC)

Amended on Tue 07 Apr 2015 07:38 AM (UTC) by Nick Gammon

Message
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

- Nick Gammon

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

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #9 on Tue 07 Apr 2015 01:16 AM (UTC)

Amended on Tue 07 Apr 2015 01:17 AM (UTC) by Nick Gammon

Message
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.

- Nick Gammon

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

Posted by Quit   (12 posts)  [Biography] bio
Date Reply #10 on Tue 07 Apr 2015 05:02 PM (UTC)

Amended on Wed 17 Jun 2015 06:47 PM (UTC) by Quit

Message
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)
[Go to top] top

Posted by Fiendish   USA  (1,641 posts)  [Biography] bio   Global Moderator
Date Reply #11 on Fri 10 Apr 2015 03:20 PM (UTC)
Message
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.

https://github.com/fiendish/aardwolfclientpackage
[Go to top] top

Posted by Nick Gammon   Australia  (21,324 posts)  [Biography] bio   Forum Administrator
Date Reply #12 on Fri 10 Apr 2015 07:50 PM (UTC)
Message
That would certainly be more efficient.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


6,171 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 FutureQuest]