You parented the itemdata vars incorrectly, just an info for everyone planning to copy that code without thought
0/10
thanks for the corrections guys, fixed, I should have paid more attention
Instead of doing the if checks, why not just keep track of the last added?
function onAddStuff(blub)
{
return ($lastAdded = parent::onAddStuff(blub));
}
(On mobile right now, will fix when I get back)
this works fine too
something like
package captureDroppedItem
{
function serverCmdDropTool(%cl,%slot)
{
parent::serverCmdDropTool(%cl,%slot);
%item = $dropItemCapture;
%item.setVelocity("0 0 100");
}
function itemData::onAdd(%db,%item)
{
$dropItemCapture = %item;
parent::onAdd(%db,%item);
}
};
activatePackage(captureDroppedItem);
I wouldn't return the parent onAdd if I were you though, it could produce console errors
either way is essentially the same, the if checks are basically completely negligible and dropping them from the code will not result in really any performance increase since it's just a boolean check