Page 1 of 1

Use Goodies

Posted: Sun Jul 17, 2011 6:05 pm
by Sabrinajewel
I have been playing sucessfully with the use goodies until i put in the "superior collection potions I, II, and III". it uses them everytime i leave combat, for what ever reason it doesn't recgonize them in my buff bar.

Any ideas???

Re: Use Goodies

Posted: Sun Jul 17, 2011 7:19 pm
by MiesterMan
The buffs probably have a different name. Have a look at the instructions again:
http://www.solarstrike.net/phpBB3/viewt ... =27&t=2406

Re: Use Goodies

Posted: Sun Jul 17, 2011 10:16 pm
by Sabrinajewel
Thank you for your link. It did help some when you mentioned the name might be wrong a double checked the spelling and the item numbers and everything was correct. My thought was about the I, II, III's so i took them out completely and it is using the # 1 potion and not reusing it after each fight but the 2nd and 3rd are not working. I used the capital i for the roman numbers any other ideas for these symbols...II...and III?

Re: Use Goodies

Posted: Sun Jul 17, 2011 11:37 pm
by lisa
I'd suguest using the Id as opposed to the name, should be some code posted a few times already about getting Id for items and also buffs.

Re: Use Goodies

Posted: Mon Jul 18, 2011 5:21 am
by rock5
lisa wrote:I'd suguest using the Id as opposed to the name, should be some code posted a few times already about getting Id for items and also buffs.
With the latest changes, using ids wont make any difference because it doesn't compare ids but gets the name for the id and compares the name. This was to stop problems with having the wrong id. Now, if the id you are using gives you the right name it will work even if it's the wrong id.

The problem is the buffs extract the numbers so if you need to use 2 or more different items that have the same name but different numbers then it's a problem. Usually for skills it's not a problem. If useGoodies could be made to check the "count" number then it could work (maybe an extra argument?).

Or just use the manual method.

Code: Select all

if not player:hasBuff("Superior Collection Potion",1) then
    inventory:useItem("Superior Collection Potion I")
end
if not player:hasBuff("Superior Collection Potion",2) then
    inventory:useItem("Superior Collection Potion II")
end
if not player:hasBuff("Superior Collection Potion",3) then
    inventory:useItem("Superior Collection Potion III")
end
Wait, that's not going to work. getBuff returns true if it's equal or higher than the "count". You may need to use your own hasbuff function. Here, I just copied it over and made a small adjustment.

Code: Select all

function HasBuffCount(buffnamesorids, count)
self:updateBuffs()

	-- for each buff the pawn has
	for i, buff in pairs(self.Buffs) do
		-- compare against each 'buffname'
		for buffname in string.gmatch(buffnamesorids,"[^,]+") do
			if type(tonumber(buffname)) == "number" then
				-- Get name from id
				buffname = GetIdName(tonumber(buffname))
				-- Take of end numbers
				buffname = parseBuffName(buffname)
			end
			if buffname == buff.Name and ( count == nil or buff.Count == count ) then
				return buff
			end
		end
	end

	return false
end
You could probably put this in a userfunction file then this should work.

Code: Select all

if not HasBuffCount("Superior Collection Potion",1) then
    inventory:useItem("Superior Collection Potion I")
end
if not HasBuffCount("Superior Collection Potion",2) then
    inventory:useItem("Superior Collection Potion II")
end
if not HasBuffCount("Superior Collection Potion",3) then
    inventory:useItem("Superior Collection Potion III")
end

Re: Use Goodies

Posted: Mon Jul 18, 2011 9:51 am
by Sabrinajewel
First off thank you for your quick response time. you guys are on top of things thats for sure.

Ok what i did was put the function block in a new file called addon_Has_Buff_Count in my userfunctions folder and the code block in my on leave combat in my profile. I had a error pop up...micromacro/scripts/rom/classes/player.lua:1254: Error in your profile: onLeaveCombat error: ...o/scripts/rom/userfunctions/addon_Has_Buff_Count.lua:2: attempt to index global 'self' <a nil value>

Did i put these in the wrong place or name the file wrong.

Thanks

Re: Use Goodies

Posted: Mon Jul 18, 2011 9:52 am
by Sabrinajewel
Correction File Name addon_HasBuffCount.lua

Re: Use Goodies

Posted: Mon Jul 18, 2011 10:14 am
by lisa
self:updateBuffs() needs to be player:updateBuffs()

Code: Select all

function HasBuffCount(buffnamesorids, count)
player:updateBuffs()

self.Buffs needs to be player.Buffs

Code: Select all

for i, buff in pairs(player.Buffs) do
Even though addon_HasBuffCount.lua will work it is better to use
userfunction_HasBuffCount.lua as the usage of addon_ is being phased out as it confused people, they thought it was an ingame addon.

Re: Use Goodies

Posted: Mon Jul 18, 2011 10:28 am
by Sabrinajewel
YAY YAY YAY YAY You guys are Awwwwsome. Thank you again for your speedy responses.