EndUser 4 Posted November 1, 2016 Share Posted November 1, 2016 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 More sharing options...
EndUser 4 Posted November 2, 2016 Author Share Posted November 2, 2016 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>m then m=a w=tt end end end; -- Heal the unit with the largest deficit if m <= .95 then CastSpellByName(SpellName, w) end </LuaScript> I get nothing, not print, not any action, etc. Suggestions? Link to comment Share on other sites More sharing options...
EndUser 4 Posted November 2, 2016 Author Share Posted November 2, 2016 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>m then m=a w=tt end end end; if m <= 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 More sharing options...
Droidz 2708 Posted November 2, 2016 Share Posted November 2, 2016 Hello, you can test your lua script in tab "Tools" > "Development Tools" > past code in textbox and click on "Lua (...)". Link to comment Share on other sites More sharing options...
Bugreporter 92 Posted November 6, 2016 Share Posted November 6, 2016 Dont use global variables in LUA. Put a "local" in front of every new Variable ! Example: Link to comment Share on other sites More sharing options...
EndUser 4 Posted November 8, 2016 Author Share Posted November 8, 2016 Yea, I've kind of given up on this. It was a useful exercise. C# seems to be a more consistent method. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now