Jump to content

Add Spell - Is Lua Script


EndUser

Recommended Posts

Hello,

I tried this in my fightclass as a spell:

t="raid";
nps=1;
npe=GetNumGroupMembers();
if npe<=4 then
    nps=0;
    t="party";
end;
print(t," ",npe)

 

With the spell settings as:

  • Combat only - False
  • Not spell, is lua script - True

 

I was hoping it would spam something like:

  • "party 0" or "party nil"

 

But instead I get nothing.  Any suggestions on how to make this work?  Eventually I hope to make a fightclass that can detect if I'm in a party or raid, then using the global var "t" have it run a loop for party2, raid1..40, etc.

Link to comment
Share on other sites

Well, I figured out that my lua script wasn't working as a spell, but if I used it as a condition then it worked.  Now I'm trying to pass "t" to another 'spell', with the below as a condition:

            <LuaScript>-- Find the unit with the largest health deficit, in range, that is alive, that doesn't have Rejuvenation
print("t ",t)            
m=0;
w=f;
local SpellName = GetSpellInfo("Rejuvenation")
for i=nps,npe do
    if i==0 then
        tt="player"
    else
        tt=t..i
    end;
if UnitExists(tt) and IsSpellInRange(SpellName,tt) and not UnitIsDeadOrGhost(tt) and not UnitBuff(tt,SpellName,nil,"PLAYER") then
        a=UnitHealth(tt) / UnitHealthMax(tt);
        if a&gt;m then
            m=a w=tt
        end
    end
end;

-- Heal the unit with the largest deficit
if m &lt;= .95 then
    CastSpellByName(SpellName, w)
end
</LuaScript>

 

I get nothing, not print, not any action, etc.  Suggestions?

Link to comment
Share on other sites

I know it's not optimal, but I got it to work with this now:

            <LuaScript>m=0;
w=f;
local SpellName = GetSpellInfo("Rejuvenation")
for i=nps,npe do
    if i==0 then
        tt="player"
    else
        tt=t..i
    end;
    
    ue=UnitExists(tt) print(ue)
    isir=IsSpellInRange(SpellName,tt) print(isir)
    uidog=UnitIsDeadOrGhost(tt) print(uidog)
    ub=UnitBuff(tt,SpellName,nil,"PLAYER") print(ub)
    
    print("----------------")
    if ue and isir and not uidog then print("TRUE") else print("FALSE") end
    print("----------------")
    
    if ue and isir and not uidog then
        a=UnitHealth(tt) / UnitHealthMax(tt);
        if a&gt;m then
            m=a w=tt
        end
    end
end;

if m &lt;= 1 and not ub then
    CastSpellByName(SpellName, w)
end;
</LuaScript>

 

The part that is driving me crazy - otherwise I like solving puzzles - is that the results are not consistent.  Sometimes it works, then other times it just doesn't.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...