PDA

View Full Version : Possible bug in CoreRPG Modifier Box onDrop code



ianmward
February 13th, 2016, 06:10
Hi,

I have found what appears to be a bug in modifierstack_core.lua
in the function onDrop()
it checks to see if the dragtype is in the acceptdrop list but appears to iterate over the list wrongly, only picking up the first.

line 71 onwards:


-- See which other potential drop types we want to accept (ignoring dice)
for _,v in pairs(acceptdrop) do
if v.type[1] == sDragType then
draginfo.setSlot(1);
ModifierStack.addSlot(draginfo.getStringData(), draginfo.getNumberData());
return true;
end
end

The XML definition for the ModifierStack has the acceptdrop defined as:

<acceptdrop>
<type>dice</type>
<type>number</type>
</acceptdrop>
with type nested inside acceptdrop but the iterator iteratates over multiple acceptdrop tags, taking the first type in each.

To fix this we can change the XML to

<acceptdrop>
<type>dice</type>
</acceptdrop>
<acceptdrop>
<type>number</type>
</acceptdrop>
which works but is not very elegant, or we can change the onDrop to:

-- See which other potential drop types we want to accept (ignoring dice)
for _,v in pairs(acceptdrop[1].type) do
if v == sDragType then
draginfo.setSlot(1);
ModifierStack.addSlot(draginfo.getStringData(), draginfo.getNumberData());
return true;
end
end
You could even iterate at both levels but that would be overkill, I think.