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:
InventoryItem < Item HeadSlot < InventoryItem id: slot1 image-source: /images/game/slots/head &position: {x=65535, y=1, z=0} BodySlot < InventoryItem id: slot4 image-source: /images/game/slots/body &position: {x=65535, y=4, z=0} LegSlot < InventoryItem id: slot7 image-source: /images/game/slots/legs &position: {x=65535, y=7, z=0} FeetSlot < InventoryItem id: slot8 image-source: /images/game/slots/feet &position: {x=65535, y=8, z=0} NeckSlot < InventoryItem id: slot2 image-source: /images/game/slots/neck &position: {x=65535, y=2, z=0} LeftSlot < InventoryItem id: slot6 image-source: /images/game/slots/left-hand &position: {x=65535, y=6, z=0} FingerSlot < InventoryItem id: slot9 image-source: /images/game/slots/finger &position: {x=65535, y=9, z=0} BackSlot < InventoryItem id: slot3 image-source: /images/game/slots/back &position: {x=65535, y=3, z=0} RightSlot < InventoryItem id: slot5 image-source: /images/game/slots/right-hand &position: {x=65535, y=5, z=0} AmmoSlot < InventoryItem id: slot10 image-source: /images/game/slots/ammo &position: {x=65535, y=10, z=0} PurseButton < Button id: purseButton size: 26 26 !tooltip: tr('Open purse') icon-source: /images/game/slots/purse icon-size: 24 24 icon-offset: 1 1 PokeHealthBar < ProgressBar id: pokeHealthBar width: 120 height: 16 !text: '0 / 0' font: verdana-11px-rounded color: #FFFFFF background-color: #053878 anchors.top: parent.top anchors.right: parent.right margin-top: 5 margin-right: 12 opacity: 0.9 PokeHealthIcon < UIButton id: pokeHealthIcon width: 130 height: 16 image-source: img/progressBar_blue image-color: white focusable: false margin-top: 5 anchors.top: parent.top anchors.right: parent.right margin-right: 7 portraitButton < UIButton id: portraitButton size: 34 34 image-source: img/2 focusable: false phantom: true OrderIcon < Item size: 36 34 image-source: img/Order anchors.top: parent.top anchors.right: parent.right margin-top: 40 margin-right: 3 phantom: true focusable: false Pokemonbar < UIButton id: pokemonbar !tooltip: ('Rope') image-source: /images/topbuttons/rope_icon.png size: 32 32 anchors.top: parent.top anchors.right: parent.right margin-top: 42 margin-right: 39 @onClick: togglePokeBar() pbButtonIni < UIButton id: playericon image-source: img/pb_apagada size: 10 9 anchors.top: parent.top anchors.left: parent.left margin-top: 47 margin-left: 80 pbButton < pbButtonIni anchors.left: prev.right margin-left: 2 MiniWindow id: inventoryWindow !text: tr('POKE INFO') icon: /images/topbuttons/inventory height: 105 @onClose: modules.game_inventory.onMiniWindowClose() &save: true MiniWindowContents PokeHealthBar PokeHealthIcon HeadSlot anchors.top: parent.top anchors.left: parent.left margin-top: 40 margin-left: 125 visible: false BodySlot anchors.top: parent.top anchors.right: parent.right margin-top: 40 margin-right: 3 LegSlot anchors.top: parent.top anchors.left: parent.left margin-top: 3 margin-left: 5 portraitButton anchors.top: parent.top anchors.left: parent.left margin-top: 3 margin-left: 5 FeetSlot anchors.top: parent.top anchors.left: parent.left margin-top: 40 margin-left: 5 NeckSlot anchors.top: parent.top anchors.left: parent.left margin-top: 3 visible: false LeftSlot anchors.top: parent.top anchors.left: parent.left margin-top: 40 margin-left: 3 visible: false FingerSlot anchors.top: parent.top anchors.left: parent.left margin-top: 40 margin-left: 45 BackSlot anchors.top: parent.top anchors.left: parent.left margin-top: 40 margin-left: 85 visible: false RightSlot anchors.top: parent.top anchors.left: parent.left margin-top: 40 margin-left: 45 visible: false AmmoSlot anchors.top: parent.top anchors.left: parent.left margin-top: 40 margin-left: 45 visible: false PurseButton anchors.top: parent.top anchors.left: parent.left margin-top: 3 visible: false OrderIcon Pokemonbarinventory.lua:
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@edit: Consegui arrumar.. Podem fechar.
Editado por DeadpoolsLink para o comentário
https://xtibia.com/forum/topic/236911-otclient-mudar-slot/Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados