if I use the lua script (the one that allows you to run lua commands directly from the Mudlet command line) here's an example of what I get:
> lua gmcp.Char.Skills.List
table {
'list': table {
1: 'Maqam'
2: 'Lay'
3: 'Haiku'
4: 'Isorhythm'
5: 'Tune'
}
'group': 'voicecraft'
}If I want to change gmcp.Char.Skills.List to give me info for, oh say - swashbuckling, this is the command I have to use (the only one that works)
> lua sendGMCP("Char.Skills.Get "..yajl.to_string({group = "swashbuckling"}));lua send("\n")
So all of that makes sense, right? The problem is when I try to use the following script:
for k, v in pairs (gmcp.Char.Skills.Groups) do
skill = {}
--echo(v.name .. ", " .. v.rank .. "\n")
skill.name = v.name
skill.rank = v.rank
sendGMCP("Char.Skills.Get "..yajl.to_string({group = v.name}))
send("\n")
skill.subskills = gmcp.Char.Skills.List
display(skill.subskills)
end
I expect that display() will show me a different table of subskills for each group. Instead, I get duplicate instances of the subskills of only one group, over and over again. Coincidentally, that group is "gathering", which is the group that gets processed on the very last iteration.
Can someone tell me what's going on? I'm new to coding and I've read all of the tutorials, but I haven't found any information to explain this behavior. The only two possible problems I can think of are:
1 - Not every skill group has subskills. "Galvanism", "Philosophy" - since they don't have subskill tables, when I try to pass them as a group via the sendGMCP command, nothing changes. gmcp.Char.Skills.List retains the values of the last group that had a subskills table.
And yet, that doesn't explain why iterations 1 through 8 - the major skills, all of which have subskill tables - aren't returning the relevant subskills. The only other thing I can think is
2 - sendGMCP() is an asynchronous call somehow, and my for loop is somehow out of sync.
Either way, if there's anyone who understands what's going on, I'd be... so appreciative of an answer. I've been pulling my hair out over this. There's a lot of documentation, but for some reason, it's either outdated, or my Mudlet client is outdated, or Achaea's not sending the information they claim they're sending, or a combination of all three.
Help please!
-Misty (aka Xerea, Perl's Bardlet)
Comments
--start script
function charSkillsGroups()
skill = {}
for _,skillset in ipairs(gmcp.Char.Skills.Groups) do
sendGMCP(string.format("Char.Skills.Get %s", yajl.to_string({group=skillset.name})))
send("\n")
end
end
function charSkillsList()
skill[gmcp.Char.Skills.List.group] = gmcp.Char.Skills.List.list
end
registerAnonymousEventHandler("gmcp.Char.Skills.Groups","charSkillsGroups")
registerAnonymousEventHandler("gmcp.Char.Skills.List","charSkillsList")
--end script
The event handlers will make it so that the appropriate function will get called whenever the relevant event is received, so this should populate your skill table if you just do AB. The skills with no abilities, like Avoidance and many of the miniskills, don't send the Char.Skills.List event, so they shouldn't cause a problem.