Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, 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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ GMCP on Aardwolf
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Quit
(16 posts) 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 | Top |
|
Posted by
| Meerclar
USA (733 posts) 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 | Top |
|
Posted by
| Quit
(16 posts) 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 | Top |
|
Posted by
| Fiendish
USA (2,534 posts) 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 | Top |
|
Posted by
| Quit
(16 posts) 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
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| Quit
(16 posts) 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)
| Top |
|
Posted by
| Fiendish
USA (2,534 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | 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.
38,087 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top