Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. -- Local variables
  2. local pokedexIcon = nil
  3. local ropeIcon = nil
  4. local autolootIcon = nil
  5.  
  6. local path = '/images/ui/pxg/topMenu_icons/'
  7. local currentSlot = 0
  8. -- End local variables
  9.  
  10. -- Public functions
  11. function init()
  12. autolootIcon = modules.client_topmenu.addCustomRightButton('autolootIcon', 'Auto Loot', path..'autoloot_icon', toggleAutoLootIcon, true)
  13. autolootIcon:setVisible(false)
  14.  
  15. pokedexIcon = modules.client_topmenu.addCustomRightButton('pokedexIcon', 'Pokedex', path..'pokedex_icon', togglePokedexIcon, true)
  16. pokedexIcon:setVisible(false)
  17.  
  18. ropeIcon = modules.client_topmenu.addCustomRightButton('ropeIcon', 'Rope', path..'rope_icon', toggleRopeIcon, true)
  19. ropeIcon:setVisible(false)
  20.  
  21. connect(g_game, { onGameStart = online,
  22. onGameEnd = offline })
  23. end
  24.  
  25. function terminate()
  26. bagIcon:destroy()
  27. fishingIcon:destroy()
  28. pokedexIcon:destroy()
  29. duelIcon:destroy()
  30. ropeIcon:destroy()
  31. bikeIcon:destroy()
  32. evolveIcon:destroy()
  33. autolootIcon:destroy()
  34. end
  35.  
  36. function offline()
  37. pokedexIcon:setVisible(false)
  38. ropeIcon:setVisible(false)
  39. autolootIcon:setVisible(false)
  40. --g_game.talk("#setSto# 66548, -1")
  41. end
  42.  
  43.  
  44. function online()
  45. pokedexIcon:setVisible(true)
  46. ropeIcon:setVisible(true)
  47. autolootIcon:setVisible(true)
  48. --g_game.talk("#setSto# 66548, 1")
  49. end
  50.  
  51. -- Complex functions
  52. function startChooseItem(releaseCallback)
  53. if not releaseCallback then
  54. error("No mouse release callback parameter set.")
  55. end
  56. local mouseGrabberWidget = g_ui.createWidget('UIWidget')
  57. mouseGrabberWidget:setVisible(false)
  58. mouseGrabberWidget:setFocusable(false)
  59.  
  60. connect(mouseGrabberWidget, { onMouseRelease = releaseCallback })
  61.  
  62. mouseGrabberWidget:grabMouse()
  63. g_mouse.pushCursor('target')
  64. end
  65.  
  66. function onClickWithMouse(self, mousePosition, mouseButton)
  67. local item = nil
  68. if mouseButton == MouseLeftButton then
  69. local clickedWidget = modules.game_interface.getRootPanel():recursiveGetChildByPos(mousePosition, false)
  70. if clickedWidget then
  71. if clickedWidget:getClassName() == 'UIMap' then
  72. local tile = clickedWidget:getTile(mousePosition)
  73. if tile then
  74. if currentSlot == 1 then
  75. item = tile:getGround()
  76. else
  77. local thing = tile:getTopMoveThing()
  78. if thing and thing:isItem() then
  79. item = thing
  80. else
  81. item = tile:getTopCreature()
  82. end
  83. end
  84. elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
  85. item = clickedWidget:getItem()
  86. end
  87. end
  88. end
  89. end
  90. if item then
  91. if currentSlot == 4 and not item:isPlayer() then
  92. modules.game_textmessage.displayFailureMessage('Use it only in players!')
  93. else
  94. local player = g_game.getLocalPlayer() --2 --6 pokedex
  95. g_game.useInventoryItemWith(player:getInventoryItem(currentSlot):getId(), item)
  96. end
  97. end
  98. g_mouse.popCursor()
  99. self:ungrabMouse()
  100. self:destroy()
  101. end
  102.  
  103. -- Toggles functions
  104. function toggleRopeIcon()
  105. currentSlot = 1
  106. startChooseItem(onClickWithMouse)
  107. end
  108.  
  109. function togglePokedexIcon()
  110. currentSlot = 6
  111. startChooseItem(onClickWithMouse)
  112. end
  113. function toggleAutoLootIcon()
  114. g_game.talk("/autoloot on")
  115. end
  116. -- End public functions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement