Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function startChooseItem(releaseCallback)
- if not releaseCallback then
- error("No mouse release callback parameter set.")
- end
- local mouseGrabberWidget = g_ui.createWidget('UIWidget')
- mouseGrabberWidget:setVisible(false)
- mouseGrabberWidget:setFocusable(false)
- connect(mouseGrabberWidget, { onMouseRelease = releaseCallback })
- mouseGrabberWidget:grabMouse()
- g_mouse.pushCursor('target')
- end
- function onClickWithMouse(self, mousePosition, mouseButton)
- local item = nil
- if mouseButton == MouseLeftButton then
- local clickedWidget = modules.game_interface.getRootPanel():recursiveGetChildByPos(mousePosition, false)
- if clickedWidget then
- if clickedWidget:getClassName() == 'UIMap' then
- local tile = clickedWidget:getTile(mousePosition)
- if tile then
- if currentSlot == 1 then
- item = tile:getGround()
- else
- local thing = tile:getTopMoveThing()
- if thing and thing:isItem() then
- item = thing
- else
- item = tile:getTopCreature()
- end
- end
- elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
- item = clickedWidget:getItem()
- end
- end
- end
- end
- if item then
- if currentSlot == 4 and not item:isPlayer() then
- modules.game_textmessage.displayFailureMessage('Use it only in players!')
- else
- local player = g_game.getLocalPlayer() --2 --6 pokedex
- g_game.useInventoryItemWith(player:getInventoryItem(currentSlot):getId(), item)
- end
- end
- g_mouse.popCursor()
- self:ungrabMouse()
- self:destroy()
- mouseclick = false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement