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-
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-