Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Local variables
- local pokedexIcon = nil
- local ropeIcon = nil
- local autolootIcon = nil
- local path = '/images/ui/pxg/topMenu_icons/'
- local currentSlot = 0
- -- End local variables
- -- Public functions
- function init()
- autolootIcon = modules.client_topmenu.addCustomRightButton('autolootIcon', 'Auto Loot', path..'autoloot_icon', toggleAutoLootIcon, true)
- autolootIcon:setVisible(false)
- pokedexIcon = modules.client_topmenu.addCustomRightButton('pokedexIcon', 'Pokedex', path..'pokedex_icon', togglePokedexIcon, true)
- pokedexIcon:setVisible(false)
- ropeIcon = modules.client_topmenu.addCustomRightButton('ropeIcon', 'Rope', path..'rope_icon', toggleRopeIcon, true)
- ropeIcon:setVisible(false)
- connect(g_game, { onGameStart = online,
- onGameEnd = offline })
- end
- function terminate()
- bagIcon:destroy()
- fishingIcon:destroy()
- pokedexIcon:destroy()
- duelIcon:destroy()
- ropeIcon:destroy()
- bikeIcon:destroy()
- evolveIcon:destroy()
- autolootIcon:destroy()
- end
- function offline()
- pokedexIcon:setVisible(false)
- ropeIcon:setVisible(false)
- autolootIcon:setVisible(false)
- --g_game.talk("#setSto# 66548, -1")
- end
- function online()
- pokedexIcon:setVisible(true)
- ropeIcon:setVisible(true)
- autolootIcon:setVisible(true)
- --g_game.talk("#setSto# 66548, 1")
- end
- -- Complex functions
- 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()
- end
- -- Toggles functions
- function toggleRopeIcon()
- currentSlot = 1
- startChooseItem(onClickWithMouse)
- end
- function togglePokedexIcon()
- currentSlot = 6
- startChooseItem(onClickWithMouse)
- end
- function toggleAutoLootIcon()
- g_game.talk("/autoloot on")
- end
- -- End public functions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement