diff --git a/modules/game_bot/functions/player.lua b/modules/game_bot/functions/player.lua index e4cb3cb..0a68d7a 100644 --- a/modules/game_bot/functions/player.lua +++ b/modules/game_bot/functions/player.lua @@ -113,9 +113,21 @@ context.setSpellTimeout = function() context.lastSpell = context.now end -context.use = g_game.useInventoryItem -context.usewith = g_game.useInventoryItemWith -context.useWith = g_game.useInventoryItemWith +context.use = function(thing, subtype) + if type(thing) == 'number' then + return g_game.useInventoryItem(thing, subtype) + else + return g_game.use(thing) + end +end +context.usewith = function(thing, target, subtype) + if type(thing) == 'number' then + return g_game.useInventoryItemWith(thing, target, subtype) + else + return g_game.useWith(item, target, subtype) + end +end +context.useWith = context.usewith context.useRune = function(itemid, target, lastSpellTimeout) if context.lastRuneUse == nil then diff --git a/modules/game_interface/gameinterface.lua b/modules/game_interface/gameinterface.lua index 7dde7a0..87d22f3 100644 --- a/modules/game_interface/gameinterface.lua +++ b/modules/game_interface/gameinterface.lua @@ -928,7 +928,6 @@ function updateSize() local height = gameMapPanel:getHeight() local width = gameMapPanel:getWidth() - print("updatesize") if not classic then local rheight = gameRootPanel:getHeight() local rwidth = gameRootPanel:getWidth() diff --git a/modules/game_prey/prey.lua b/modules/game_prey/prey.lua index dd90440..b3557b9 100644 --- a/modules/game_prey/prey.lua +++ b/modules/game_prey/prey.lua @@ -60,6 +60,7 @@ function timeleftTranslation(timeleft, forPreyTimeleft) -- in seconds end function init() connect(g_game, { + onGameStart = check, onGameEnd = hide, onResourceBalance = onResourceBalance, onPreyFreeRolls = onPreyFreeRolls, @@ -73,11 +74,14 @@ function init() preyWindow = g_ui.displayUI('prey') preyWindow:hide() - preyButton = modules.client_topmenu.addRightGameToggleButton('preyButton', tr('Preys'), '/images/topbuttons/prey', toggle) + if g_game.isOnline() then + check() + end end function terminate() disconnect(g_game, { + onGameStart = check, onGameEnd = hide, onResourceBalance = onResourceBalance, onPreyFreeRolls = onPreyFreeRolls, @@ -89,7 +93,9 @@ function terminate() onPreySelection = onPreySelection }) - preyButton:destroy() + if preyButton then + preyButton:destroy() + end preyWindow:destroy() if msgWindow then msgWindow:destroy() @@ -97,6 +103,17 @@ function terminate() end end +function check() + if g_game.getFeature(GamePrey) then + if not preyButton then + preyButton = modules.client_topmenu.addRightGameToggleButton('preyButton', tr('Preys'), '/images/topbuttons/prey', toggle) + end + elseif preyButton then + preyButton:destroy() + preyButton = nil + end +end + function hide() preyWindow:hide() if msgWindow then @@ -106,6 +123,9 @@ function hide() end function show() + if not g_game.getFeature(GamePrey) then + return hide() + end preyWindow:show() preyWindow:raise() preyWindow:focus()