Check if you have a particular skill using GMCP

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Check if you have a particular skill using GMCP

Post by tsuujin » Sun Sep 19, 2010 4:58 am

It's just a tester function, half written. I fire it off several times inbetween mud output to see if it's refreshing anything with the sendGMCP calls.

User avatar
Vadi
Posts: 4727
Joined: Sat Mar 14, 2009 3:13 pm

Re: Check if you have a particular skill using GMCP

Post by Vadi » Sun Sep 19, 2010 1:17 pm

This is an Achaea bug with GMCP sending. It only sent all events once I requested output from the MUD as well...

So as a temporary workaround, do send("\n") after you send the GMCP requests and it should be more or less OK.

kaeus
Posts: 50
Joined: Thu Dec 31, 2009 4:33 pm

Re: Check if you have a particular skill using GMCP

Post by kaeus » Mon Sep 20, 2010 8:32 am

This is what I'm currently using to basically check if I have a skill, but I'm more passing it the required rank/percent for the skill, and only using the Groups table. Also, I know I kinda need to redo it to actually trigger off of the event, but this works for now!
Code: [show] | [select all] lua
ksys.temp.skillranks = {"Inept",
"Novice",
"Apprentice",
"Capable",
"Adept",
"Skilled",
"Gifted",
"Expert",
"Virtuoso",
"Fabled",
"Mythical",
"Transcendent"}

function parseSkills()
	if not gmcp.Char.Skills then
		sendGMCP("Char.Skills.Get")
	end

	ksys.temp.skills = {}

	for i,v in pairs(gmcp.Char.Skills.Groups) do
		local skill = yajl.to_value(gmcp.Char.Skills.Groups[i])
		ksys.temp.skills[skill.name] = {skill.rank, tonumber(skill.percent)}
	end
end

function canUse(skill, rankRequired, percentRequired)
	parseSkills()

	if ksys.temp.skills[skill] then
		if getSkillrankValue(ksys.temp.skills[skill][1]) >= getSkillrankValue(rankRequired)
			and ksys.temp.skills[skill][2] >= percentRequired
		then
			return true
		end
	end

	return false
end

function getSkillrankValue(skillrank)
	for i,v in pairs(ksys.temp.skillranks) do
		if v:lower() == skillrank:lower() then
			return i
		end
	end
	return 0
end

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Check if you have a particular skill using GMCP

Post by Heiko » Mon Sep 20, 2010 10:07 am

There's no way that this can work reliably. To begin with, you need to request a skills data set from the server. The server will answer this request asynchronously i.e. you need to hook up an event handler that parses the skill data set *when it gets delivered*.

kaeus
Posts: 50
Joined: Thu Dec 31, 2009 4:33 pm

Re: Check if you have a particular skill using GMCP

Post by kaeus » Mon Sep 20, 2010 10:10 am

Heiko wrote:There's no way that this can work reliably. To begin with, you need to request a skills data set from the server. The server will answer this request asynchronously i.e. you need to hook up an event handler that parses the skill data set *when it gets delivered*.
It works, but its because I request the skills, send a blank line, then run this when I log in. The data is still in gmcp.Char.Skills.Groups, it just wont keep updated, so it currently doesn't really work in real time this way. This is why it needs to be hooked to the event handler.

User avatar
Vadi
Posts: 4727
Joined: Sat Mar 14, 2009 3:13 pm

Re: Check if you have a particular skill using GMCP

Post by Vadi » Tue Jan 18, 2011 6:19 pm

By the way, this bug is so because MCCP is enabled and Rapture doesn't flush data properly. I've reminded them of this again today - perhaps this might get a fix after years.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests