• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient OTClient, Can't go above 4 buttons without error.

bobby299

New Member
Joined
Nov 11, 2009
Messages
20
Reaction score
0
Hi, I have an issue I cant really understand.

I can't go above 4 buttons at the same time. I have 5 in the code and I have rotated button 4 and 5 and both work. Just not at the same time.

New to OTClient but been going at it for hours now so maybe someone can see my issue.

1721768185896.png
playerbars.lua
LUA:
playerBarsWindow = nil
skillsButton = nil
battleButton = nil
vipButton = nil
fullScreenButton = nil
analyzerButton = nil
playerBarsButton = nil
botButton = nil

function init()

connect(g_game, {
    onGameStart = online,
    onGameEnd = offline
})

  playerBarsWindow = g_ui.loadUI('playerbars', modules.game_interface.getRightPanel())
  playerBarsWindow:disableResize()

  skillsButton = playerBarsWindow:recursiveGetChildById('SkillsButton')
  battleButton = playerBarsWindow:recursiveGetChildById('BattleButton')
  vipButton = playerBarsWindow:recursiveGetChildById('VipButton')
  fullscreenButton = playerBarsWindow:recursiveGetChildById('FullScreenButton')
  analyzerButton = playerBarsWindow:recursiveGetChildById('analyzerButton')
 
  playerBarsWindow:getChildById('contentsPanel'):setMarginTop(3)
 
  playerBarsWindow:open()
  playerBarsWindow:setup()

end

function terminate()

disconnect(g_game, {
    onGameStart = online,
    onGameEnd = offline
})

  playerBarsWindow:destroy()
end

function offline()
  local lastPlayerBars = g_settings.getNode('LastPlayerBars')
  if not lastPlayerBars then
    lastPlayerBars = {}
  end

  local player = g_game.getLocalPlayer()
  if player then
    local char = g_game.getCharacterName()

    lastPlayerBars[char] = {
      checkSkill = getCheckedButtons(skillsButton),
      checkBattle = getCheckedButtons(battleButton),
      checkVip = getCheckedButtons(vipButton),
    }
    g_settings.setNode('LastPlayerBars', lastPlayerBars)
  end
end

function online()
  local player = g_game.getLocalPlayer()
  if player then
    local char = g_game.getCharacterName()
    local lastPlayerBars = g_settings.getNode('LastPlayerBars')
    if not table.empty(lastPlayerBars) then
      if lastPlayerBars[char] then

         skillsButton:setChecked(lastPlayerBars[char].checkSkill)
         battleButton:setChecked(lastPlayerBars[char].checkBattle)
         vipButton:setChecked(lastPlayerBars[char].checkVip)

      end
    end
  end
end

function getCheckedButtons(button)
 if button:isChecked() then
   return 1
 else
   return nil
 end
end

function onMiniWindowClose()
  playerBarsWindow:open()
end

playerbars.otui
Code:
SpecialMiniWindow < UIMiniWindow
  font: cipsoftFont
  icon-rect: 5 3 13 12
  width: 30
  height: 18
  focusable: true
  &minimizedHeight: 20

  $on:
    image-border-bottom: 2

  UIWidget
    id: miniwindowTopBar
    margin-right: 2
    margin-left: 2
    margin-top: 2

  UIButton
    id: closeButton

  UIButton
    id: minimizeButton


    id: miniwindowScrollBar
    anchors.top: parent.top
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    step: 0
    margin-top: -0
    margin-right: 0
    margin-bottom: 0
    pixels-scroll: true

    $!on:
      width: 0

  ResizeBorder
    id: bottomResizeBorder
    height: 3
    minimum: 48
    margin-left: 3
    margin-right: 3
    enabled: false

SpecialMiniWindow
  id: playerBarsWindow
  height: 28
  @onClose: modules.game_inventory.onMiniWindowClose()
  &save: true
  &notMinimize: true

  MiniWindowContents
    ButtonBox
      id: SkillsButton
      font: cipsoftFont
      !text: tr('Skills')
      size: 35 20     
      anchors.left: parent.left
      anchors.top: parent.top
      margin: 0 0
      @onCheckChange: modules.game_skills.toggle()

    ButtonBox
      id: BattleButton
      font: cipsoftFont
      anchors.left: SkillsButton.right
      anchors.top: SkillsButton.top
      margin-left: 2
      text: Battle
      size: 35 20     
      @onCheckChange: modules.game_battle.toggle()

    ButtonBox
      id: VipButton
      font: cipsoftFont
      anchors.left: BattleButton.right
      anchors.top: BattleButton.top
      margin-left: 2
      text: Vip
      size: 30 20
      @onCheckChange: modules.game_viplist.toggle()

    ButtonBox
      id: analyzerButton
      font: cipsoftFont
      anchors.left: VipButton.right
      anchors.top: VipButton.top
      margin-left: 2
      text: Exp/h
      size: 35 20               
      @onClick: modules.game_exph.toggle()
      
    ButtonBox
      id: fullscreenButton
      font: cipsoftFont
      anchors.left: analyzerButton.right
      anchors.top: analyzerButton.top
      margin-left: 2
      text: Exp/h 2
      size: 20 20               
      @onClick: modules.game_exph.toggle()

playerbars.otmod
Code:
Module
  name: game_playerbars
  description: Displays vip, skills, battle, and logout
  author: edubart, BeniS
  website: www.otclient.info
  sandboxed: true
  scripts: [ playerbars ]
  @onLoad: init()
  @onUnload: terminate()

I now that both of the buttons open the same module, I'm just trying to troubleshoot atm =)

Any help is much appreciated!
 
Back
Top