PDA

View Full Version : nil window in client windowlist



phantomwhale
September 28th, 2011, 12:20
Hit a programming wall, possibly related to https://www.fantasygrounds.com/forums/showthread.php?t=14927

I've got a windowlist for my client-side combat tracker. On the list, there are two methods as follows :



function onFilter(w)
if w.list.getWindows()[1].chartype.getValue() == "pc" then
return true
end
if w.list.getWindows()[1].show_npc.getValue() ~= 0 then
return true
end
return false
end

function onSortCompare(w1, w2)
if not w1 or not w1.getInitiativeCard() then
return false
elseif not w2 or not w2.getInitiativeCard() then
return true
else
return w1.getInitiativeCard().compareTo(w2.getInitiativeC ard()) < 0
end
end


The problem I am seeing is when the host adds a new entry to the main combat tracker, these methods are throwing errors, with the "w" parameter of the onFilter method and the "w2" parameter of the onSortCompare method coming up nil (they are not nil on the Host's copy of this window).

Now, you'll see the windowlist elements contain more windowlists. So I thought this might be the issue, although it's throwing an error that "w" is nil for the onFilter method, so I'm not sure if the sub-windowlists are the problem or not.

In the first instance, has anyone heard of a client-side windowlist having "nil" windows when a new database node (with sub nodes) is added to the list ? And is there good coding practice to deal with this ?

Thanks for any help,
-PW-

phantomwhale
September 29th, 2011, 03:46
After removing all the scripting except for the essentials from the client combat tracker, I have got it to the point now where it works - but it doesn't receive NEW data.

E.g. it reacts fine to existing window list elements and deletions, but when I add a new list element, it only appears on the hosts minitracker. For the client to see it, I need to close and reshare the minitracker.

This sounds very similar to what Ikael was seeing in the thread (link in previous post) - has something changed around 2.8.0 for this ? Or is there something I can try to ensure clients get new data (set as holder ? mark data as shareable ?)

phantomwhale
September 30th, 2011, 08:37
Well, this is odd.

As shown above, I am sorting each element of the windowlist by using values from the first value of it's sub-windowlist.

But for the client, the following is returning a blank string every time:

win.combatants.getWindows()[1].getChild("name").getValue()

Howver, this statement always returns an actual string value:

local key, node = next(win.getDatabaseNode().getChild("combatants").getChildren())
node.getChild("name").getValue()

The only problem now is that next(win.getDatabaseNode().getChild("combatants").getChildren()) does NOT always return the database node of the "first" window - only by calling the getWindows() function can I get the order as specified by my onSortCompare() method. However, this method is failing, probaly from being a windowlist within a window within a windowlist, and the timing that come from such a deep arrangement.

Still stuck, hoping for some inspiration on what to try next ?!

Moon Wizard
October 2nd, 2011, 09:42
Responding to your e-mail.

Regards,
JPG