PDA

View Full Version : Windowlist applySort() problems



Brenn
November 16th, 2008, 21:56
Ok I have a windowlist, have onSortCompare set up and am calling applySort(true).

It works fine if I'm running in host mode alone, as soon as I have a client connect it gets all screwy. I'm sending the command for the client to sort his windowlist at the same time. Sometimes mine will sort and his will not or vice versa. Sometimes it will only sort a couple of the windows in his list.

anyway here is the relevant code:


function onSortCompare(w1, w2)
local tempSet1 = w1.getSelectedSet();
local selWidth1 = 0;
local selHeight1 = 0;
if tempSet1 ~= nil then
selWidth1 = tempSet1.width;
selHeight1 = tempSet1.height;
end
local tempSet2 = w2.getSelectedSet();
local selWidth2 = 0;
local selHeight2 = 0;
if tempSet2 ~= nil then
selWidth2 = tempSet2.width;
selHeight2 = tempSet2.height;
end
if sortByWidth then
if selWidth1 == selWidth2 then
return selHeight2 > selHeight1;
else
return selWidth2 > selWidth1;
end
else
if selHeight1 == selHeight2 then
return selWidth2 > selWidth1;
else
return selHeight2 > selHeight1;
end
end
end
function setSortByWidth(value)
sortByWidth = value;
if User.isHost() then
if trackerCommand.order == "" then
if sortByWidth then
trackerCommand.order = "sortByWidth";
else
trackerCommand.order = "sortByHeight";
end
ChatManager.deliverTable(trackerCommand);
else
trackerCommand.order = "";
applySort(true);
end
else
applySort(true);
end
end
function onInit()
allowWasteSelection = false;
trackerCommand = {};
trackerCommand.tableType = "trackerCommand";
trackerCommand.order = "";
sortByWidth = true;
end


I have buttons that call setSortByWidth, passing it either true or false. The host broadcasts the command to everyone and then (theoretically at least) does the apply sort after the command is recieved. I've put prints all through this thing and the routines are being called. I'm extremely puzzled.

PneumaPilot
November 16th, 2008, 22:00
I'm just curious: what are you sorting on the players' ends?

Brenn
November 16th, 2008, 22:06
The die roll sets in the windowlist.

If roll 1 has three 2's in it and roll 2 has two 7's, then if it were sorted by width it would be:

roll 1 - 2 2 2
roll 2 - 77

but if it were sorted by height it would be:

roll 2 - 77
roll 1 - 222

Brenn
November 16th, 2008, 22:49
Wish I could delete this post, the code was doing exactly what I told it to elsewhere.

It's fixed and working like a charm.

Foen
November 17th, 2008, 06:26
Glad I could help ;)

Brenn
November 17th, 2008, 13:58
Glad I could help ;)

:D

As always you were key! ;)