Page 1 of 1
Q: How to check target's (de)buff name?
Posted: Sat Feb 25, 2012 8:41 am
by kkulesza
This code works:
Code: Select all
player:target(obj.Address);
player:update();
target = player:getTarget();
if target:hasBuff("xxx") then
...
but this does not:
Code: Select all
player:target(obj.Address);
player:update();
target = player:getTarget();
target:updateBuffs();
debuffName=target.Buffs[1].Name
if debuffName=="xxx" then
...
I want to get the name of target's first debuff
Re: Q: How to check target's (de)buff name?
Posted: Sat Feb 25, 2012 9:05 am
by Administrator
As far as I can tell, that should work. hasBuff() and the buffs array may contain slightly different information for the name. Try printing the name out and see how it matches up against what you are comparing it to. It could be something as simple as 'Seal of Light' verse 'Seal of Light III'.
Re: Q: How to check target's (de)buff name?
Posted: Sat Feb 25, 2012 9:05 am
by lisa
you probably arn't doing it right, try this
Code: Select all
player:update() target = player:getTarget() print(target.Buffs[1].Name)
Lizard Blood
Or like admin said you just have the name wrong.
Re: Q: How to check target's (de)buff name?
Posted: Sat Feb 25, 2012 9:56 am
by kkulesza
It's not about mismatched string. It's about an error.
Example A. working code:
Code: Select all
player:target(obj.Address);
player:update();
target = player:getTarget();
target:updateBuffs();
--print(target.Buffs[1].Name)
if target:hasBuff("Lizard Blood") then
Examplel B. works until "target.Buffs[1].Name" line:
Code: Select all
player:target(obj.Address);
player:update();
target = player:getTarget();
target:updateBuffs();
print(target.Buffs[1].Name)
if target:hasBuff("Lizard Blood") then
Error code from mm window:
Code: Select all
Lizard Blood
Did not find any crashed game clients.
3:48pm - [string "..."]:76: attempt to index field '?' (a nil value)
I don't know what it means.
Re: Q: How to check target's (de)buff name?
Posted: Sat Feb 25, 2012 10:00 am
by rock5
Means there is no first buff so no Name. Try
Code: Select all
if target.Buffs[1] then
print(target.Buffs[1].Name)
else
print("No Buffs")
end
Re: Q: How to check target's (de)buff name?
Posted: Sat Feb 25, 2012 10:04 am
by kkulesza
rock5 wrote:Means there is no first buff so no Name. Try
Code: Select all
if target.Buffs[1] then
print(target.Buffs[1].Name)
else
print("No Buffs")
end
hmmm
but it did print the buff name
it's in the first line in code from mm window
Re: Q: How to check target's (de)buff name?
Posted: Sat Feb 25, 2012 10:15 am
by rock5
I can't understand how it errored on that line but still managed to print the name. Maybe the error was from something else.
Re: Q: How to check target's (de)buff name?
Posted: Sat Feb 25, 2012 10:23 am
by kkulesza
rock5 wrote:
Code: Select all
if target.Buffs[1] then
print(target.Buffs[1].Name)
else
print("No Buffs")
end
ok i did try this code and it works. Now i see where i was wrong.
My code was in a loop. So First time there was a buff and it did print it, but next time there was no buff and there was error.
Thx for help