Ir para conteúdo

Featured Replies

Postado
  • Autor
IconPoke < Button
  width: 40
  height: 60
  image-size: 40 40
  image-clip: 0 0 0 0
  image-color: white
  focusable: false
  anchors.top: parent.top
  anchors.left: parent.left

HealthBar1 < ProgressBar
  id: healthBar
  background-color: #ff4444
  anchors.top: parent.top
  anchors.left: parent.left
  anchors.right: parent.right
  size: 60  5
  margin: 1  
  
Poke < UIProgressRect
  background: #585858AA
  percent: 100
  focusable: false
  font: verdana-11px-rounded
  color: #FFFFFF
  
Window
  id: optionsWindow
  !text: tr('Pokes')
  size: 255  72
  focusable: false
  &save: true
  opacity: 0.95

http://Pokexmortal.com/ ONLINE!

Todo mondo Bienvenido :D ! Serv serio 24/7 comunidade Latina!

  • Respostas 17
  • Visualizações 7.2k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • manda seu otui pra eu poder fazer a funcao que interpreta o a sendcancel

  • substitui por isso local barPoke = nil local icons = {}   -- Public functions function init()    barPoke = g_ui.displayUI('barpoke', modules.game_interface.getRootPanel())    barPoke:setVisible(fals

Postado

no caso cada health bar tem q ter um id diferente, tipo healthbar1,healthbar2 ate o 6

 

vc tem q registrar isso na function init()

connect(g_game, 'onTextMessage', onPokes)

e isso na function terminate()

disconnect(g_game, 'onTextMessage', onPokes)

ai adicona essa function 

function onPokes(mode, text)
if not g_game.isOnline() then return end
   if mode == MessageModes.Failure then 
      if string.find(text, 'Pokehp/') then
         local t = text:explode('/')
         table.remove(t, 1)
         for i = 1, #t do
            Window:recursiveGetChildById('HealthBar'..i):setValue(t[i], 0, 100)
         end
      end
   end
end

eu acho que pode dar algum erro pois fiz correndo essa funcao ^^, no lugar de "Window" voce coloca o nome da sua window

Editado por Aberos (veja o histórico de edições)

Postado
  • Autor

ERROR: protected lua call failed: LUA ERROR:
/game_extrapokebar/barpoke.lua:102: attempt to index a nil value
stack traceback:
	[C]: ?
	/game_extrapokebar/barpoke.lua:102: in function </game_extrapokebar/barpoke.lua:95>

:(

Vou postar o LUA:

local barPoke = nil
local icons = {}

-- Public functions
function init()
   barPoke = g_ui.displayUI('barpoke', modules.game_interface.getRootPanel())
   barPoke:setVisible(false)  
   barPoke:move(250,50)
   
   connect(g_game, 'onTextMessage', getParams)
   connect(g_game, 'onTextMessage', onPokes)
   connect(g_game, { onGameEnd = hide } )
   connect(g_game, { onGameStart = show } )

   createIcons()
end

function terminate()
   disconnect(g_game, { onGameEnd = hide })
   disconnect(g_game, 'onTextMessage', getParams)
   disconnect(g_game, 'onTextMessage', onPokes)

   destroyIcons()
   barPoke:destroy()
end


function getParams(mode, text)
if not g_game.isOnline() then return end
   if mode == MessageModes.Failure then 
      if string.sub(text, 1, 9) == "BarClosed" then
      hide()
      elseif string.sub(text, 1, 7) == "Pokebar" then
         atualizarBar(text)
   end
end
end

function atualizarBar(text)
if not g_game.isOnline() then return end
local talk = "/pokamon"
show()
cleanAllPokes()
local t = string.explode(text, "/")
for i=2, #t do
x= i-1
local poke = t[i]
local zafrada = i-1
local progress = icons['Icon'..x].progress
changeIconPoke(x, poke)
progress.onClick = function() g_game.talk(talk.." "..poke..""..zafrada.."")
end 
end
end


function changeIconPoke(i, poke)
if not g_game.isOnline() then return end
   local icon = icons['Icon'..i].icon
local image = "pokes/"..poke..".png"
   icon:setImageSource(image)
end

function createIcons()
   local d = 36
   local image = "pokes/portait.png"
   for i = 1, 6 do
      local icon = g_ui.createWidget('IconPoke', barPoke)
      local icon1 = g_ui.createWidget('HealthBar', icon)
      local progress = g_ui.createWidget('Poke', barPoke) 
      icon:setId('Icon'..i)  
      progress:setId('Progress'..i)  
      icons['Icon'..i] = {icon = icon, progress = progress, dist = (i == 1 and -5 or i == 2 and 35 or d + ((i-2)*38)), event = nil}
      icon:setMarginLeft(icons['Icon'..i].dist)
      icon:setImageSource(image)
      icon:setMarginTop(-5)
      icon1:setMarginTop(30)
      icon1:setMarginLeft(-3)
      icon1:setMarginRight(-6)
      progress:fill(icon:getId())
   end
end

function cleanAllPokes()
   local image = "pokes/portait.png"
   for i = 1, 6 do
       local icon = icons['Icon'..i].icon
       icon.onClick = function() end
      icon:setImageSource(image)
     local progress = icons['Icon'..i].progress
     progress.onClick = function() g_game.talk("") end  
end               
end

function onPokes(mode, text)
if not g_game.isOnline() then return end
   if mode == MessageModes.Failure then 
      if string.find(text, 'Pokehp/') then
         local t = text:explode('/')
         table.remove(t, 1)
         for i = 1, #t do
            barPoke:recursiveGetChildById('HealthBar'..i):setValue(t[i], 0, 100)
         end
      end
   end
end

function hide()
   barPoke:setVisible(false)
end

function show()
   barPoke:setVisible(true)
end
-- End public functions

EDIT: eu removei os "%" no comando para que assim nao tenha errores, mais o LUA em OTC sigue com errores jaja :c

http://Pokexmortal.com/ ONLINE!

Todo mondo Bienvenido :D ! Serv serio 24/7 comunidade Latina!

Postado
  • Solução

substitui por isso

local barPoke = nil
local icons = {}
 
-- Public functions
function init()
   barPoke = g_ui.displayUI('barpoke', modules.game_interface.getRootPanel())
   barPoke:setVisible(false)  
   barPoke:move(250,50)
   
   connect(g_game, 'onTextMessage', getParams)
   connect(g_game, 'onTextMessage', onPokes)
   connect(g_game, { onGameEnd = hide } )
   connect(g_game, { onGameStart = show } )
 
   createIcons()
end
 
function terminate()
   disconnect(g_game, { onGameEnd = hide })
   disconnect(g_game, 'onTextMessage', getParams)
   disconnect(g_game, 'onTextMessage', onPokes)
 
   destroyIcons()
   barPoke:destroy()
end
 
 
function getParams(mode, text)
if not g_game.isOnline() then return end
   if mode == MessageModes.Failure then 
      if string.sub(text, 1, 9) == "BarClosed" then
      hide()
      elseif string.sub(text, 1, 7) == "Pokebar" then
         atualizarBar(text)
   end
end
end
 
function atualizarBar(text)
if not g_game.isOnline() then return end
local talk = "/pokamon"
show()
cleanAllPokes()
local t = string.explode(text, "/")
for i=2, #t do
x= i-1
local poke = t[i]
local zafrada = i-1
local progress = icons['Icon'..x].progress
changeIconPoke(x, poke)
progress.onClick = function() g_game.talk(talk.." "..poke..""..zafrada.."")
end 
end
end
 
 
function changeIconPoke(i, poke)
if not g_game.isOnline() then return end
   local icon = icons['Icon'..i].icon
local image = "pokes/"..poke..".png"
   icon:setImageSource(image)
end
 
function createIcons()
   local d = 36
   local image = "pokes/portait.png"
   for i = 1, 6 do
      local icon = g_ui.createWidget('IconPoke', barPoke)
      local icon1 = g_ui.createWidget('HealthBar', icon)
      local progress = g_ui.createWidget('Poke', barPoke) 
      icon:setId('Icon'..i)  
      progress:setId('Progress'..i)  
      icons['Icon'..i] = {icon = icon, progress = progress, dist = (i == 1 and -5 or i == 2 and 35 or d + ((i-2)*38)), event = nil}
      icon:setMarginLeft(icons['Icon'..i].dist)
      icon:setImageSource(image)
      icon:setMarginTop(-5)
      icon1:setMarginTop(30)
      icon1:setMarginLeft(-3)
      icon1:setMarginRight(-6)
      icon1:setId('HealthBar'..i) 
      progress:fill(icon:getId())
   end
end
 
function cleanAllPokes()
   local image = "pokes/portait.png"
   for i = 1, 6 do
       local icon = icons['Icon'..i].icon
       icon.onClick = function() end
      icon:setImageSource(image)
     local progress = icons['Icon'..i].progress
     progress.onClick = function() g_game.talk("") end  
end               
end
 
function onPokes(mode, text)
if not g_game.isOnline() then return end
   if mode == MessageModes.Failure then 
      if string.find(text, 'Pokehp/') then
         local t = text:explode('/')
         table.remove(t, 1)
         for i = 1, #t do
            barPoke:recursiveGetChildById('HealthBar'..i):setValue(t[i], 0, 100)
         end
      end
   end
end
 
function hide()
   barPoke:setVisible(false)
end
 
function show()
   barPoke:setVisible(true)
end
-- End public functions

Editado por Aberos (veja o histórico de edições)

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