Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado

Olá, estou tentando copiar a pokebar do client desktop para o client mobile, mas estou com o seguinte erro:

Citar

Unable to load module 'poke_bar': /modules/poke_bar/pokebar.lua:16: attempt to index upvalue 'pokeBarWindow' (a nil value)

stack traceback:

[C]: in function '__index'

/modules/poke_bar/pokebar.lua:16: in function 'init'

/modules/poke_bar/pokebar.otmod:10 :[@onLoad]:1 : in main chuck

[C]: in function 'autoLoadModules'

/init.lua:70: in function "loadModules'

/init.lua:84: in main chunk

 

Código do pokebar.lua

local janelaWindow = nil
local pokeBarWindow = nil
local pokeBarButton = nil
local barList = {}
local barVar = nil
 
function init()
   connect(g_game, { onGameStart = online,
                      onGameEnd = offline})
   janelaWindow = g_ui.displayUI('janela.otui')
   pokeBarButton = modules.client_topmenu.addRightGameToggleButton('pokeBarButton', tr('Poke Bar') .. ' ', '/images/topbuttons/bar', toggle)
   pokeBarButton:setWidth(25)
   pokeBarButton:setOn(false)
   pokeBarWindow = g_ui.displayUI('pokebar',  modules.game_interface.getRightPanel())
 
   pokeBarWindow:move(250,50)
   pokeBarWindow:hide()
   janelaWindow:hide()
 
   ProtocolGame.registerExtendedOpcode(160, receive)
   connect(g_game, 'onTextMessage', portrait)
end
 
function portrait(mode, text)
    if not g_game.isOnline() then return end
    if mode == MessageModes.Failure then
        local t = text:explode(",")
        table.remove(t, 1)
       
        if string.find(text, 'p#') then
            for i = 6, 1, -1 do
                barVar = #t
                pokeBarWindow:setHeight((44*#t))
                if i <= #t then
                    local t2 = t[i]:explode("|")
                    pokeBarWindow:getChildById('slot'..i):setVisible(true)
                    pokeBarWindow:getChildById('slot'..i):setItemId(tonumber(t2[1]))
                    pokeBarWindow:getChildById('bar'..i).onClick = function() g_game.talk('!@pokebar@ '..tonumber(t2[3])) end
                    pokeBarWindow:getChildById('L'..i):setColor("#FFFF00")
                    pokeBarWindow:getChildById('bar'..i):setImageSource("bar.png")
                    pokeBarWindow:getChildById('bar'..i):setVisible(true)
                    pokeBarWindow:getChildById('B'..i):setVisible(true)
                    receive(i, t2[2], tonumber(t2[4]), tonumber(t2[5]), tonumber(t2[6]))
                else
                    pokeBarWindow:getChildById('slot'..i):setItemId(3283)
                    pokeBarWindow:getChildById('slot'..i):setVisible(false)
                    pokeBarWindow:getChildById('bar'..i):setVisible(false)
                    pokeBarWindow:getChildById('B'..i):setVisible(false)
                    pokeBarWindow:getChildById('bar'..i).onClick = function()  end
                    receive(i, "", 0, 0, 0)
                end
            end
        elseif string.find(text, 'pGS') then
            local t2 = t[1]:explode("|")
            lifeBarAtual(tonumber(t2[2]), tonumber(t2[1]), t2[3])
        elseif string.find(text, 'KGT') then
                local t2 = t[1]:explode("|")
                    levelBarAtual(t2[1], 0)
        end
    end
end
 
function levelBarAtual(i)
    pokeBarWindow:getChildById('bar'..i):setImageSource("bar1.png")
    pokeBarWindow:getChildById('L'..i):setColor("black")
end
 
function lifeBarAtual(i, hp)
    color = '#'
    pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#ff0000")
    if tonumber(hp) == 0 then
        pokeBarWindow:getChildById('HP'..i):setText("Desmaiado")
        pokeBarWindow:getChildById('HP'..i):setPercent(100);
        pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020")
        pokeBarWindow:getChildById('L'..i):setColor("gray")
        pokeBarWindow:getChildById('bar'..i):setImageSource("bar2.png")
    else
        color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0)
               
        pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color)
        if tonumber(hp) == -1 then
            pokeBarWindow:getChildById('HP'..i):setPercent(100);
            pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ;
        else
            pokeBarWindow:getChildById('HP'..i):setPercent(hp);
            pokeBarWindow:getChildById('HP'..i):setText(hp.."%");
        end
    end
end
 
function receive(i, name, hp, boost)
    color = '#'
    pokeBarWindow:getChildById('L'..i):setText(name)
    pokeBarWindow:getChildById('B'..i):setText("+"..boost)
    pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#ff0000")
    if tonumber(hp) == 0 then
        pokeBarWindow:getChildById('HP'..i):setText("Desmaiado")
        pokeBarWindow:getChildById('HP'..i):setPercent(100);
        pokeBarWindow:getChildById('HP'..i):setBackgroundColor("#202020")
        pokeBarWindow:getChildById('L'..i):setColor("gray")
        pokeBarWindow:getChildById('bar'..i):setImageSource("bar2.png")
    else
        color = color..string.format("%.2x",255-math.ceil(hp)*2.5)..string.format("%.2x",math.ceil(hp)*2.5)..string.format("%.2x",0)
               
        pokeBarWindow:getChildById('HP'..i):setBackgroundColor(color)
        if tonumber(hp) == -1 then
            pokeBarWindow:getChildById('HP'..i):setPercent(100);
            pokeBarWindow:getChildById('HP'..i):setText(string.format( "%3d %%", 100 ) ) ;
        else
            pokeBarWindow:getChildById('HP'..i):setPercent(hp);
            pokeBarWindow:getChildById('HP'..i):setText(hp.."%");
        end
    end
   
end
 
function terminate()
  disconnect(g_game, { onGameStart = online,
                         onGameEnd = offline})
  pokeBarWindow:destroy()
  janelaWindow:destroy()
  disconnect(g_game, 'onTextMessage', portrait)
end
 
function toggle()
  if pokeBarButton:isOn() then
    pokeBarWindow:hide()
    pokeBarButton:setOn(false)
  else
    pokeBarWindow:show()
    pokeBarButton:setOn(true)
  end
end
 
function online()
    if g_game.isOnline() then
        pokeBarWindow:show()
        janelaWindow:show()
        pokeBarButton:setOn(true)
    end
end
 
function offline()
    pokeBarWindow:hide()
    janelaWindow:hide()
    pokeBarButton:setOn(false)
end
 
function onMoveBottomPanelHoverChange(widget)
  if widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then
    addEvent(function() g_effects.fadeIn(widget, 250) end)
  elseif not widget:isHovered() and not g_mouse.isPressed(MouseLeftButton) then
    addEvent(function() g_effects.fadeOut(widget, 250) end)
  end
end
 
function getMoveBottomPanel()
  return gameRootPanel:recursiveGetChildById('moveBottomPanel')
end

Código do pokebar.otmod

Module  
  name: poke_bar
  description: pokebar
  author: Viktor
  website: http://potsystems.blogspot.com
  sandboxed: true
  autoload: true
  autoload-priority: 1000
  scripts: [ pokebar ]
  @onLoad: init()
  @onUnload: terminate()

Procurei em tudo que é fórum e não achei. Estou no aguardo.

 

Editado por Pablin
Especificar mais ainda a publicação (veja o histórico de edições)

  • Pablin mudou o título para [Erro] Pokebar no OTClientV8 (mobile) com erro.

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo