07-22-11, 04:16 PM | #1 |
Table for health status raid member
hello
I've written a working table for health status raid member. the table was tested many times in raid with no problems. I've never learn any programming language... just read some codes of lua I just submit here in case someone could tell me if we can improve the code to avoid "garbage" Code:
function jps_RaidStatus(self) table.remove(jps.RaidStatus) local subgroup = nil local group_type group_type="raid"; nps=1; npe=GetNumRaidMembers(); if npe==0 then group_type="party" nps=0; npe=GetNumPartyMembers(); end; for i=nps,npe do if i==0 then unit="player" else unit=group_type..i end --name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(raidIndex); --Index of raid member between 1 and MAX_RAID_MEMBERS (40). If you specify an index that is out of bounds, the function returns nil. --subgroup - Integer - The raid party this character is currently a member of. Raid subgroups are numbered as on the standard raid window. --GetNumRaidMembers() returns number of players in your raid group, including yourself; or 0 if you are not in a raid group if GetNumRaidMembers()==0 then subgroup = unit else subgroup = select(3,GetRaidRosterInfo(i)) end jps.RaidStatus[unit] = {["name"] = UnitName(unit),["hp"] = UnitHealthMax(unit) - UnitHealth(unit),["hpct"] = UnitHealth(unit) / UnitHealthMax(unit),["index"] = subgroup} end local function sortMyTable(a,b) return jps.RaidStatus[a]["hp"] > jps.RaidStatus[b]["hp"] end --for k,v in pairs(jps.RaidStatus) do -- print(k,v.name,v.hp) --end local sortedKeys = {} for k,v in pairs(jps.RaidStatus) do table.insert(sortedKeys, k) end table.sort(sortedKeys, sortMyTable) --for i,k in ipairs(sortedKeys) do -- print(jps.RaidStatus[k].hp,jps.RaidStatus[k].name) --end TargetTable1 = sortedKeys[1] TargetTable2 = sortedKeys[2] TargetTable3 = sortedKeys[3] TargetTable4 = sortedKeys[4] TargetTable5 = sortedKeys[5] if (#sortedKeys)==1 then TargetTable2=TargetTable1 TargetTable3=TargetTable1 TargetTable4=TargetTable1 TargetTable5=TargetTable1 end if IsShiftKeyDown() then print(jps.RaidStatus[TargetTable1].hp, jps.RaidStatus[TargetTable1].name, "Index =",jps.RaidStatus[TargetTable1].index) print(jps.RaidStatus[TargetTable2].hp, jps.RaidStatus[TargetTable2].name, "Index =",jps.RaidStatus[TargetTable2].index) print(jps.RaidStatus[TargetTable3].hp, jps.RaidStatus[TargetTable3].name, "Index =",jps.RaidStatus[TargetTable3].index) print(jps.RaidStatus[TargetTable4].hp, jps.RaidStatus[TargetTable4].name, "Index =",jps.RaidStatus[TargetTable4].index) else print("Shift down please") end end every 0.1 sec with OnUpdate(self,elapsed) Last edited by htordeux : 07-22-11 at 04:23 PM. |
|
07-28-11, 05:03 AM | #2 | |
Have you tried to do an own oUF layout? You won't be disspointed. |
||
07-28-11, 07:49 AM | #3 | ||
I'm not sure what exactly is happening in your code, but this is what I tried to make from it. You were also leaking some globals and not reusing tables
Can you explain a bit more on this? Last edited by Ketho : 07-28-11 at 09:33 AM. |
|||
07-28-11, 01:44 PM | #4 | |
I read through the API to get, what he was talking about... Do you register your frame to an event (UNIT_HEALTH) or are you using an OnUpdate-mechanism. Both together just made no sense to me...
__________________
|
||
07-31-11, 01:29 PM | #5 |
Thanks for yours answers, I'll do some change , check if it works and submit it again
|
|
WoWInterface » Developer Discussions » Lua/XML Help » Table for health status raid member |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|