Page 1 of 2
Check if you have a particular skill using GMCP
Posted: Fri Sep 17, 2010 6:13 pm
by Vadi
There are two ways to do this - either request info on it specifically, or request the list of skills you have in a skillset. I'll show the first way.
The essence is the same as doing
ab <skillset> <skill> command - if you get information about it back, then you have the skill.
Step one: ask for AB information by:
sendGMCP("Char.Skills.Get "..yajl.to_string({group = <skillset>, name = <skill>}))
Step two: connect an event handler to
gmcp.Char.Skills.Info event. When you receive it, check if
gmcp.Char.Skills.Info.info is "" or not - if it is, then you don't have that skill - if it's the description of the skill, then you have it.
ie, I have the skill:
Code: Select all
table {
'group': 'discipline'
'skill': 'focusbody'
'info': 'Syntax: FOCUS BODY
Paralysis prevents you from doing anything, a nasty situation to be in. But all you need
do is move your little toe before movement returns. By focusing your entire will upon
your body, you can break out of paralysis, or the psionic ailments of leg lock or throat
lock.
'
I don't have the skill:
Code: Select all
table {
'group': 'arts'
'skill': 'yellowtint'
'info': ''
}
Pros: easy to check for specific skills.
Cons: skillsets like Tattoos will always tell you information about a skill, just like the ab command. Achaea also will always return the ABs.
The other way is via gmcp.Char.Skills.List - I'll let someone else post a tut on how to do that
Re: Check if you have a particular skill using GMCP
Posted: Sun Sep 19, 2010 3:34 am
by tsuujin
I'm having an issue with this. Sometimes the call works to populate the table, and sometimes it doesn't.
i can do:
sendGMCP([[Char.Skills.Get {group: "survival"}]])
and sometimes it'll populate the gmcp.Char.Skills table, and sometimes it won't. The problem is that the debug tells me that the GMCP event has been recieved, even though I can't see it populating.
Re: Check if you have a particular skill using GMCP
Posted: Sun Sep 19, 2010 3:37 am
by tsuujin
Ah, nevermind. It doesn't work as I expected, but it does work. I expected sending Char.Skills.Get would result in an instant gmcp line from the mud, but it actually doesn't seem to come through until a timed tick or a new line from the mud.
Re: Check if you have a particular skill using GMCP
Posted: Sun Sep 19, 2010 3:46 am
by Vadi
I would double-check this on a blank profile. The proper GMCP table is populated before the event - and hence the red debug gmcp line - are raised, if I understood your problem correctly.
Re: Check if you have a particular skill using GMCP
Posted: Sun Sep 19, 2010 3:56 am
by tsuujin
I've tested it several times. I send the request, nothing happens. I type "look" and the table magically becomes populated properly.
Re: Check if you have a particular skill using GMCP
Posted: Sun Sep 19, 2010 3:59 am
by tsuujin
For the record: I was trying to write a script that would parse through a list of skillsets looking for particular skills very quickly. This has now become far, far more complex if I have to wait for table population over a long period of time.
Re: Check if you have a particular skill using GMCP
Posted: Sun Sep 19, 2010 4:01 am
by Vadi
What MUD?
I just completed my auto-setup of skills via GMCP today - by quering individual skills / checking a list, and it is instantaneous. Kaeus' makes use of GMCP for skills on Aetolia as well and he hasn't reported any issues.
Re: Check if you have a particular skill using GMCP
Posted: Sun Sep 19, 2010 4:46 am
by tsuujin
Achaea
Re: Check if you have a particular skill using GMCP
Posted: Sun Sep 19, 2010 4:51 am
by tsuujin
Here's the alias body I'm using to test this:
function getSkillCheckTable(searchList)
local sf = [[Char.Skills.Get {"group": "%s"}]]
local has = {}
for group,skillList in pairs(searchList) do
msg.print("sending: "..sf:format(group))
sendGMCP(sf:format(group))
for _,skill in pairs(skillList) do
has[skill] = false
for _,x in pairs(gmcp.Char.Skills.List.list) do
if x:lower() == skill:lower() then
msg.print("yes")
has[skill] = true
break
end
end
end
end
return has
end
tbl = nil
tbl = getSkillCheckTable({
["twoarts"] = {"bladename"},
["striking"] = {"constitution"}
})
display(tbl)
The function works fine, as long as the gmcp...List.List element is set -before- the function runs. otherwise it'll fail, and fail, and fail, until some text is recieved from the mud, and then one of the two tables will populate fine.
Re: Check if you have a particular skill using GMCP
Posted: Sun Sep 19, 2010 4:55 am
by Vadi
um. it's 1am and it seems to be that you're expecting GMCP output within 1 function. it's asyncronous communication though, you're supposed to hook on the gmcp event and check the data inside the event handler.