diff --git a/modules/game_interface/widgets/uigamemap.lua b/modules/game_interface/widgets/uigamemap.lua index 04ce91ff..e5924a9d 100644 --- a/modules/game_interface/widgets/uigamemap.lua +++ b/modules/game_interface/widgets/uigamemap.lua @@ -30,16 +30,30 @@ function UIGameMap:onDragLeave(droppedWidget, mousePos) end function UIGameMap:onDrop(widget, mousePos) - if not self:canAcceptDrop(widget, mousePos) then return false end + if not self:canAcceptDrop(widget, mousePos) then + return false + end local tile = self:getTile(mousePos) - if not tile then return false end + if not tile then + return false + end local thing = widget.currentDragThing - local toPos = tile:getPosition() - local thingPos = thing:getPosition() - if thingPos.x == toPos.x and thingPos.y == toPos.y and thingPos.z == toPos.z then return false end + if not thingPos then + return false + end + + local thingTile = thing:getTile() + if thingPos.x ~= 65535 and not thingTile then + return false + end + + local toPos = tile:getPosition() + if thingPos.x == toPos.x and thingPos.y == toPos.y and thingPos.z == toPos.z then + return false + end if thing:isItem() and thing:getCount() > 1 then modules.game_interface.moveStackableItem(thing, toPos)