Thread Tools Display Modes
05-16-13, 06:58 AM   #21
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
group still full :/

numInGroup[group] is sometimes nill and then it has problems because its not a swap

Last edited by Anja : 05-16-13 at 07:26 AM.
  Reply With Quote
05-16-13, 03:47 PM   #22
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Yes, that's correct -- if the group is empty (not listed in the numInGroup table) or has fewer than 5 members, you don't need to swap, you can just move the player into an empty slot in the group.

Try adding another call to UpdateRaidState() after this line:

Code:
SetRaidSubgroup(current[name].index, group)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
05-17-13, 06:45 AM   #23
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
same problem:

grp 1:

a
b
c
d
e

grp 2:

f

string: f:1&b:2

= group is full
and b goes to 2

so f is not swapping


now i have:

group1:

a
c
d
e

group2:

f
b

funny to see, but i have always the same problem as my first post *g*

Last edited by Anja : 05-17-13 at 07:02 AM.
  Reply With Quote
05-20-13, 10:36 AM   #24
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
*push* please
  Reply With Quote
05-20-13, 06:42 PM   #25
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Bumping your thread isn't going to magically give me more hours to spend writing code for people on forums, or magically give me access to a raid group who will sit around while I test your code, sorry. When I have time to look at it, I will. Until then, I don't have time, so I don't have anything to add to the thread, which is why I haven't posted anything.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
05-24-13, 03:34 PM   #26
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
create a char on gilneas eu and i will give you instant 10 chars in one raid to test this problem, i'm "Ikuria" on Gilneas
  Reply With Quote
05-29-13, 05:29 AM   #27
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
i'm at my end, i didnt find the problem, why the f****** group is still full
  Reply With Quote
05-29-13, 09:31 AM   #28
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Try this (just a slightly modified version of Phanx's code)
If it doesn't work, I'll have a look at a different solution over the next couple days.
Code:
local f = CreateFrame("Frame", "Raidstring", UIParent)
f:SetPoint("CENTER")
f:SetSize(400, 125)
f:Hide()

f:SetBackdrop({
	bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", tileSize = 32, tile = true,
	edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", edgeSize = 32,
	insets = { left = 11, right = 12, top = 12, bottom = 11 }
})

f.Header = f:CreateTexture(nil, "ARTWORK")
f.Header:SetPoint("CENTER", f, "TOP")
f.Header:SetSize(139, 40)
f.Header:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
f.Header:SetTexCoord(58/256, 196/256, 0, 39/64)

f.HeaderText = f:CreateFontString(nil, "OVERLAY", "GameFontNormal")
f.HeaderText:SetPoint("CENTER", f.Header)
f.HeaderText:SetText("Raidstring")

f:EnableMouse(true)
f:SetMovable(true)
f.TitleRegion = f:CreateTitleRegion()
f.TitleRegion:SetAllPoints(f.Header)

f.EditBox = CreateFrame("EditBox", "$parentEditBox", f, "InputBoxTemplate")
f.EditBox:SetPoint("TOP", f.Header, "BOTTOM")
f.EditBox:SetSize(300, 16)
f.EditBox:SetAltArrowKeyMode(false)
f.EditBox:SetAutoFocus(false)
f.EditBox:SetFontObject(GameFontHighlightSmall)
f.EditBox:SetMaxLetters(0) -- no limit

f.EditBox:SetScript("OnEnterPressed", function(self)
	f:Hide()
	f:SortRaid(self:GetText())
end)
f.EditBox:SetScript("OnEscapePressed", function(self)
	f:Hide()
end)

f.CloseButton = CreateFrame("Button", "$parentCloseButton", f, "OptionsButtonTemplate")
f.CloseButton:SetPoint("BOTTOM", 0, 20)
f.CloseButton:SetText(APPLY)
f.CloseButton:SetScript("OnClick", function()
	f:Hide()
	f:SortRaid(f.EditBox:GetText())
end)

f:SetScript("OnHide", function()
	f.EditBox:ClearHistory()
end)

------------------------------------------------------------------------

local current, numInGroup = {}, {}

local function UpdateRaidState()
	wipe(numInGroup)
	wipe(current)
	for i = 1, GetNumGroupMembers() do
		local name, rank, subgroup, level, class, fileName, zone, online, isDead, role, isML = GetRaidRosterInfo(i)
		current[name] = { index = i, group = subgroup }
		numInGroup[subgroup] = (numInGroup[subgroup] or 0) + 1
	end
end

function f:SortRaid(str)
	if not str or strlen(str) == 0 or not IsInRaid() then
		return
	end
	if not UnitIsGroupLeader("player") and not UnitIsGroupAssistant("player") then
		return DEFAULT_CHAT_FRAME:AddMessage(format("%sRaidString:|r %s", NORMAL_FONT_COLOR_CODE, "You must be raid leader or promoted to sort the raid!"))
	end

	-- Get a snapshot of the current raid layout:
	UpdateRaidState()

	local wanted = {}
	-- Build a map of the desired raid layout:
	for name, group in string.gmatch(str, "([^&:]+):(%d+)") do
		-- Ignore named players not in the raid.
		if current[name] then
			wanted[name] = group
		end
	end
	
	local dirty
	-- Look for players not in the wanted group and move them:
	for name, group in pairs(wanted) do
		if current[name].group ~= group then
			if numInGroup[group] then
				if numInGroup[group] < 5 then
					-- Just move them:
					SetRaidSubgroup(current[name].index, group)
					dirty = true
				else
					-- Look for someone to swap with:
					for xname, xdata in pairs(current) do
						if xdata.group == group and wanted[xname] ~= group then
							-- Do the swap:
							SwapRaidSubgroup(current[name].index, xdata.index)
							dirty = true
						end
					end
				end
			else
				SetRaidSubgroup(current[name].index, group)
				dirty = true
			end
		end
		if (dirty) then
			UpdateRaidState()
			dirty = nil
		end
	end
end

------------------------------------------------------------------------

SLASH_RAIDSTRING1 = "/rs"

SlashCmdList["RAIDSTRING"] = function()
	if not IsInRaid() then
		return
	end
	local name = UnitName("player")
	local realm = GetRealmName()
	local guild = IsInGuild and GetGuildInfo("player") or ""

	local xml = "<RaidInfo><Info>Raidassist</Info><Password>W2Any"..realm.."dEAv"..name.."2AxaS</Password><Realm>"..realm.."</Realm><Guild>"..guild.."</Guild><Name>"..name.."</Name><PlayerInfos>"
	for i = 1, GetNumGroupMembers() do
		local localizedClass, englishClass = UnitClass("raid"..i)
		local name, online = UnitName("raid"..i)
		xml = xml.."<key"..i.."><name>"..name.."</name><class>"..englishClass.."</class></key"..i..">"
	end
	xml = xml.."</PlayerInfos></RaidInfo>"

	f.EditBox:SetText(xml)
	f.EditBox:HighlightText()
	f:Show()
end

------------------------------------------------------------------------

SLASH_MAKERAID1 = "/rm"

SlashCmdList["MAKERAID"] = function()
	f:Show()
end
  Reply With Quote
06-01-13, 06:01 AM   #29
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
still the same problem
the script always goes to the else of if numInGroup[group] then
dont know why, but its not working well with this numInGroup

i think the numingroup is always nil:

attempt to compare nil with number

when i delete the if numingroup

Last edited by Anja : 06-01-13 at 06:21 AM.
  Reply With Quote
06-01-13, 08:00 AM   #30
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
The group you get from gmatch() is still a string so you need to run tonumber() on it.
Code:
	local wanted = {}
	-- Build a map of the desired raid layout:
	for name, group in str:gmatch("([^&:]+):(%d+)") do
		-- Ignore named players not in the raid.
		if current[name] then
			wanted[name] = tonumber(group)
		end
	end
  Reply With Quote
06-01-13, 11:44 AM   #31
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
oh oooooh oooooooh i think it works... omg just an int problem, what a ...
  Reply With Quote
06-17-13, 04:15 PM   #32
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
... no the sorting is still not right, the script have problems with the "swapped"- players, they sorted in wrong positions O.o
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » SwapRaidSubgroup with String...


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off