InventorySlotStyles = {
[InventorySlotHead] = "HeadSlot",
[InventorySlotNeck] = "NeckSlot",
[InventorySlotBack] = "BackSlot",
[InventorySlotBody] = "BodySlot",
[InventorySlotRight] = "RightSlot",
[InventorySlotLeft] = "LeftSlot",
[InventorySlotLeg] = "LegSlot",
[InventorySlotFeet] = "FeetSlot",
[InventorySlotFeet] = "FeetSlot",
[InventorySlotFinger] = "FingerSlot",
[InventorySlotAmmo] = "AmmoSlot"
}
local pbs = {}
local duelIcon = nil
local bagIcon = nil
local fishingIcon = nil
local pokedexIcon = nil
local ropeIcon = nil
local badgeIcon = nil
local currentSlot = 0
local pokebarWindow = nil
inventoryWindow = nil
inventoryPanel = nil
inventoryButton = nil
purseButton = nil
healthPokemon = nil
pokeHealthTooltip = 'Your pokemon health is %d out of %d.'
local pokebar = nil
local icons = {}
local namesPokes = ''
function init()
connect(LocalPlayer, { onInventoryChange = onInventoryChange })
connect(g_game, 'onTextMessage', onPokeHealthChange)
connect(g_game, { onGameStart = refresh })
connect(g_game, 'onTextMessage', onPokeHealthChange)
connect(LocalPlayer, { onManaChange = onManaChange })
connect(g_game, 'onTextMessage', onPokes)
connect(g_game, 'onTextMessage', onPokesLife)
g_keyboard.bindKeyDown('Ctrl+I', toggle)
inventoryButton = modules.client_topmenu.addRightGameToggleButton('inventoryButton', ('Poke Info') .. ' (Ctrl+I)', '/images/topbuttons/pokemon_icon', toggle)
inventoryButton:setOn(true)
bagIcon = modules.client_topmenu.addRightGameToggleButton('bag_icon', 'Bag', '/images/topbuttons/bag_icon', toggleBagIcon, true)
bagIcon:setOn(false)
fishingIcon = modules.client_topmenu.addRightGameToggleButton('fishingIcon', 'Fishing', '/images/topbuttons/fishing_icon', toggleFishingIcon, true)
pokedexIcon = modules.client_topmenu.addRightGameToggleButton('pokedexIcon', 'Pokedex', '/images/topbuttons/pokedex_icon', togglePokedexIcon, true)
badgeIcon = modules.client_topmenu.addRightGameToggleButton('badgeIcon', 'Insignias', '/images/topbuttons/insignia_on', toggleBadgeIcon, true)
badgeIcon:setOn(false)
inventoryWindow = g_ui.loadUI('inventory', modules.game_interface.getRightPanel())
inventoryWindow:disableResize()
inventoryPanel = inventoryWindow:getChildById('contentsPanel')
pokebarWindow = g_ui.displayUI('pokebar')
pokebarButton = inventoryWindow:recursiveGetChildById("pokemonbar")
purseButton = inventoryPanel:getChildById('purseButton')
local function purseFunction()
local purse = g_game.getLocalPlayer():getInventoryItem(InventorySlotPurse)
if purse then
g_game.use(purse)
end
end
purseButton.onClick = purseFunction
refresh()
pokebarWindow:hide()
inventoryWindow:setup()
createPbs()
end
function terminate()
disconnect(LocalPlayer, { onInventoryChange = onInventoryChange })
disconnect(g_game, { onGameStart = refresh })
disconnect(g_game, 'onTextMessage', onPokeHealthChange)
disconnect(LocalPlayer, { onManaChange = onManaChange })
disconnect(g_game, 'onTextMessage', onPokes)
disconnect(g_game, 'onTextMessage', onPokesLife)
g_keyboard.unbindKeyDown('Ctrl+I')
inventoryWindow:destroy()
inventoryButton:destroy()
pokebarWindow:destroy()
end
function refresh()
local player = g_game.getLocalPlayer()
for i = InventorySlotFirst, InventorySlotPurse do
if g_game.isOnline() then
onInventoryChange(player, i, player:getInventoryItem(i))
else
onInventoryChange(player, i, nil)
end
end
if not player then return end
onManaChange(player, player:getMana(), player:getMaxMana())
purseButton:setVisible(g_game.getFeature(GamePurseSlot))
end
function toggle()
if inventoryButton:isOn() then
inventoryWindow:close()
inventoryButton:setOn(false)
inventoryButton:setIcon('/images/topbuttons/pokemon_icon')
else
inventoryWindow:open()
inventoryButton:setOn(true)
inventoryButton:setIcon('/images/topbuttons/pokemon_icon_apagado')
end
end
function onMiniWindowClose()
inventoryButton:setOn(false)
end
function createPbs()
for i = 1, 6 do
pbs[i] = g_ui.createWidget((i == 1 and 'pbButtonIni' or 'pbButton'), inventoryWindow)
pbs[i]:setId('pb'..i)
end
end
function toggleRopeIcon()
end
function togglePokeBar()
currentSlot = 1
startChooseItem(onClickWithMouse)
end
-- hooked events
function onInventoryChange(player, slot, item, oldItem)
if slot > InventorySlotPurse then return end
if slot == InventorySlotPurse then
if g_game.getFeature(GamePurseSlot) then
purseButton:setEnabled(item and true or false)
end
return
end
local itemWidget = inventoryPanel:getChildById('slot' .. slot)
if item then
itemWidget:setStyle('Item')
itemWidget:setItem(item)
else
itemWidget:setStyle(InventorySlotStyles[slot])
itemWidget:setItem(nil)
end
end
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
function toggleBagIcon()
if bagIcon:isOn() then
bagIcon:setOn(false)
bagIcon:setIcon('/images/topbuttons/bag_icon')
else
bagIcon:setOn(true)
bagIcon:setIcon('/images/topbuttons/bag_icon_apagado')
end
local player = g_game.getLocalPlayer()
g_game.useInventoryItem(player:getInventoryItem(3):getId())
end
function toggleBadgeIcon()
if badgeIcon:isOn() then
badgeIcon:setOn(false)
badgeIcon:setIcon('/images/topbuttons/insignia_on')
else
badgeIcon:setOn(true)
badgeIcon:setIcon('/images/topbuttons/insignia_off')
end
local player = g_game.getLocalPlayer()
g_game.useInventoryItem(player:getInventoryItem(5):getId())
end
function toggleFishingIcon()
currentSlot = 10
startChooseItem(onClickWithMouse)
end
function togglePokedexIcon()
currentSlot = 6
startChooseItem(onClickWithMouse)
end
function onPokeHealthChange(mode, text)
if not g_game.isOnline() then return end
if mode == MessageModes.Failure then
local pokeHealthBar = inventoryWindow:recursiveGetChildById("pokeHealthBar")
if string.find(text, '#ph#,') then
local t = text:explode(',')
local hp, maxHp = tonumber(t[2]), tonumber(t[3])
pokeHealthBar:setText(hp .. ' / ' .. maxHp)
inventoryWindow:recursiveGetChildById("pokeHealthBar"):setTooltip(tr(pokeHealthTooltip, hp, maxHp))
pokeHealthBar:setValue(hp, 0, maxHp)
end
end
end
function onManaChange(localPlayer, mana, maxMana)
for i = 1, 6 do
if i > tonumber(mana) then
pbs[i]:setImageSource('img/pb_apagada')
else
pbs[i]:setImageSource('img/pb_acessa')
end
end
end
function onPokes(mode, text)
if not g_game.isOnline() then return end
if mode == MessageModes.Failure then
if text:find("p#") then
local t = string.explode(text, ",")
for i = 2, #t do
pokebar = pokebarWindow:recursiveGetChildById('poke'..(i-1))
if t[i] == namesPokes then return end
pokebar:setImageSource('img/'..t[i]..'.png')
pokebar.onClick = function() g_game.talk('/goaction '..t[i]) end
end
end
end
end
function onPokesLife(mode, text)
if not g_game.isOnline() then return end
if mode == MessageModes.Failure then
if text:find("#life#") then
local t = string.explode(text, ",")
for l = 2, #t do
if t[l] == namesPokes then return end
local pokeHealth = pokebarWindow:recursiveGetChildById("poke"..(l-1))
local Life = tonumber(t[l]) or 100
pokeHealth:setTooltip(Life.."%")
end
end
end
end
Pergunta
Deadpools 5
Então galera.. Eu queria que alguem me ajudasse a mudar o Slot do meu inventario..
Esse Slot:
Alguem poderia me ajudar?
Isso é mudado no inventorio..
Segue os scripts..
Inventory.otui:
inventory.lua:
@edit: Consegui arrumar.. Podem fechar.
Editado por DeadpoolsLink para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados