Help with GMCP Autosipper

Post Reply
Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Help with GMCP Autosipper

Post by Delrayne »

Alright, so I've created an autosipper based off this prompt:
Code: [show] | [select all] lua
H:363 M:418 E:1718 W:1990 X:0.36 <eb> <db> 
Trigger to match:
^H:(\d+) M:(\d+) E:\d+ W:\d+ X:\d+\.?\d* <([eb-]+)> <([psdbf@]*)> $
With the following Lua code to run:
Code: [show] | [select all] lua
Delrayne_Sipping()
echo("\n" .. status.current_health) -- to see if GMCP updates the variable(Which it doesn't)
In my scripts section I define all the variables and the function used as follows:
Code: [show] | [select all] lua
Drink_Balance = true
status = {

        current_health = 1,
        max_health = 1,
        current_mana = 1,
        max_mana = 1,
        current_endurance = 1,
        max_endurance = 1,
        current_willpower = 1,
        max_willpower = 1,
        next_level = 1,
        last_exp = 1
}

function CharVitals() 

        status.current_health = math.floor(gmcp.Char.Vitals.hp / 11)
        status.max_health = math.floor(gmcp.Char.Vitals.maxhp / 11)
        status.current_mana = math.floor(gmcp.Char.Vitals.mp / 11)
        status.max_mana = math.floor(gmcp.Char.Vitals.maxmp / 11)
        status.current_endurance = math.floor(gmcp.Char.Vitals.ep / 11)
        status.max_endurance = math.floor(gmcp.Char.Vitals.maxep / 11)
        status.current_willpower = math.floor(gmcp.Char.Vitals.wp / 11)
        status.max_willpower = math.floor(gmcp.Char.Vitals.maxwp / 11)
        status.next_level = gmcp.Char.Vitals.nl

end

function Delrayne_Sipping()
--Set values to sip health below
	local Heal_Health = 308 --Drink health if health is less than or equal to 85% of max health
	local Heal_Mana = 355 --Drink mana if mana is less than or equal to 85% of max mana
--Check if health or mana is below their healing values
	if (status.current_health <= Heal_Health) then
			if (Drink_Balance) then --Do we have sipping balance?
				Drink_Balance = false --Keeps us from spamming in case of lag. Need a timer for reset though
				send("drink health")
			end
	elseif (status.current_mana <= Heal_Mana) then
			if (Drink_Balance) then
				Drink_Balance = false
				send("drink mana")
			end
	end
end
I've registed the gmcp.Char.Vitals event in the script as well as made sure that GMCP is enabled and restarted Mudlet multiple times.

Now, for the problem. The prompt trigger works like a charm, but something seems to be wrong in the Delrayne_Sipping() function or the CharVitals() function. I'm assuming CharVitals since GMCP isn't updating according to the echo done in the prompt trigger. So what I get is it sipping health over and over and over because its reading 'status.current_health' as 1 rather than my actual health.

Please, any help will be greatly appreciated. Thank you for your time and patience. I only hope I explained the problem well enough to be understood, and provided ample material for everyone to see what might be wrong.

Delrayne
Posts: 159
Joined: Tue Jun 07, 2011 7:07 pm
Contact:

Re: Help with GMCP Autosipper

Post by Delrayne »

Well, I tinkered with it enough to fix the issue. Thanks anyways guys! or gals.

macro
Posts: 7
Joined: Mon Jun 06, 2011 6:31 pm

Re: Help with GMCP Autosipper

Post by macro »

you declared CharVitals() but then never used it... maybe call it first thing in the sipping function?

tbh i'm not sure what purpose the CharVitals() function servers

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

Re: Help with GMCP Autosipper

Post by Vadi »

Imperians stats are divided by 11 on the prompt but they send the actual amounts for GMCP

Post Reply