• 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 Module doesnt load after restarting otclient

MikeOT

Well-Known Member
Joined
Jan 22, 2017
Messages
232
Solutions
2
Reaction score
86
Ok, so I've been editing one of the modules, and I finally managed to make a new window. So far, so good.

It works as intended thus far, but then I encountered a problem: When I exit otclient and restart it, my new module doesn't load in on its own. If I open up my modules and load it manually, it works.

What am I missing to make it automatically load like the others?


lua:
Code:
professionsWindow = nil
professionsButton = nil

function init()
  connect(LocalPlayer, {})
  connect(g_game, {
    onGameStart = refresh,
    onGameEnd = offline
  })

  professionsButton = modules.client_topmenu.addRightGameToggleButton('professionsButton', tr('Professions') .. ' (Ctrl+R)', '/images/topbuttons/professions', toggle)
  professionsButton:setOn(true)
  professionsWindow = g_ui.loadUI('professions', modules.game_interface.getRightPanel())

  g_keyboard.bindKeyDown('Ctrl+R', toggle)


  professionsWindow:setup()
end

function terminate()
  disconnect(LocalPlayer, {})
  disconnect(g_game, {
    onGameStart = refresh,
    onGameEnd = offline
  })

  g_keyboard.unbindKeyDown('Ctrl+R')
  professionsWindow:destroy()
  professionsButton:destroy()
end

function toggle()
  if professionsButton:isOn() then
    professionsWindow:close()
    professionsButton:setOn(false)
  else
    professionsWindow:open()
    professionsButton:setOn(true)
  end
end



function onMiniWindowClose()
  professionsButton:setOn(false)
end

otmod:
Code:
Module
  name: game_professions
  description: Professions Window
  author: baxnie, edubart
  website: https://github.com/edubart/otclient
  sandboxed: true
  scripts: [ professions ]
  @onLoad: init()
  @onUnload: terminate()
  dependencies:
    - game_interface

otui:
Code:
SkillFirstWidget < UIWidget

SkillButton < UIButton
  height: 21
  margin-bottom: 2
  anchors.horizontalCenter: parent.horizontalCenter
  &onClick: onSkillButtonClick

SmallSkillButton < SkillButton
  height: 14

SkillNameLabel < GameLabel
  font: verdana-11px-monochrome
  anchors.left: parent.left
  anchors.top: parent.top
  anchors.bottom: parent.bottom

SkillValueLabel < GameLabel
  id: value
  font: verdana-11px-monochrome
  text-align: topright
  anchors.right: parent.right
  anchors.top: parent.top
  anchors.bottom: parent.bottom
  anchors.left: prev.left

SkillPercentPanel < ProgressBar
  id: percent
  background-color: green
  height: 5
  margin-top: 15
  anchors.left: parent.left
  anchors.right: parent.right
  anchors.top: parent.top
  phantom: false

MiniWindow
  id: professionsWindow
  !text: tr('Professions')
  height: 150
  icon: /images/topbuttons/professions
  @onClose: modules.game_professions.onMiniWindowClose()
  &save: true

  MiniWindowContents
    padding-left: 5
    padding-right: 5
    layout: verticalBox
 
Solution
Ok, so I've been editing one of the modules, and I finally managed to make a new window. So far, so good.

It works as intended thus far, but then I encountered a problem: When I exit otclient and restart it, my new module doesn't load in on its own. If I open up my modules and load it manually, it works.

What am I missing to make it automatically load like the others?


lua:
Code:
professionsWindow = nil
professionsButton = nil

function init()
  connect(LocalPlayer, {})
  connect(g_game, {
    onGameStart = refresh,
    onGameEnd = offline
  })

  professionsButton = modules.client_topmenu.addRightGameToggleButton('professionsButton', tr('Professions') .. ' (Ctrl+R)', '/images/topbuttons/professions', toggle)...
Ok, so I've been editing one of the modules, and I finally managed to make a new window. So far, so good.

It works as intended thus far, but then I encountered a problem: When I exit otclient and restart it, my new module doesn't load in on its own. If I open up my modules and load it manually, it works.

What am I missing to make it automatically load like the others?


lua:
Code:
professionsWindow = nil
professionsButton = nil

function init()
  connect(LocalPlayer, {})
  connect(g_game, {
    onGameStart = refresh,
    onGameEnd = offline
  })

  professionsButton = modules.client_topmenu.addRightGameToggleButton('professionsButton', tr('Professions') .. ' (Ctrl+R)', '/images/topbuttons/professions', toggle)
  professionsButton:setOn(true)
  professionsWindow = g_ui.loadUI('professions', modules.game_interface.getRightPanel())

  g_keyboard.bindKeyDown('Ctrl+R', toggle)


  professionsWindow:setup()
end

function terminate()
  disconnect(LocalPlayer, {})
  disconnect(g_game, {
    onGameStart = refresh,
    onGameEnd = offline
  })

  g_keyboard.unbindKeyDown('Ctrl+R')
  professionsWindow:destroy()
  professionsButton:destroy()
end

function toggle()
  if professionsButton:isOn() then
    professionsWindow:close()
    professionsButton:setOn(false)
  else
    professionsWindow:open()
    professionsButton:setOn(true)
  end
end



function onMiniWindowClose()
  professionsButton:setOn(false)
end

otmod:
Code:
Module
  name: game_professions
  description: Professions Window
  author: baxnie, edubart
  website: https://github.com/edubart/otclient
  sandboxed: true
  scripts: [ professions ]
  @onLoad: init()
  @onUnload: terminate()
  dependencies:
    - game_interface

otui:
Code:
SkillFirstWidget < UIWidget

SkillButton < UIButton
  height: 21
  margin-bottom: 2
  anchors.horizontalCenter: parent.horizontalCenter
  &onClick: onSkillButtonClick

SmallSkillButton < SkillButton
  height: 14

SkillNameLabel < GameLabel
  font: verdana-11px-monochrome
  anchors.left: parent.left
  anchors.top: parent.top
  anchors.bottom: parent.bottom

SkillValueLabel < GameLabel
  id: value
  font: verdana-11px-monochrome
  text-align: topright
  anchors.right: parent.right
  anchors.top: parent.top
  anchors.bottom: parent.bottom
  anchors.left: prev.left

SkillPercentPanel < ProgressBar
  id: percent
  background-color: green
  height: 5
  margin-top: 15
  anchors.left: parent.left
  anchors.right: parent.right
  anchors.top: parent.top
  phantom: false

MiniWindow
  id: professionsWindow
  !text: tr('Professions')
  height: 150
  icon: /images/topbuttons/professions
  @onClose: modules.game_professions.onMiniWindowClose()
  &save: true

  MiniWindowContents
    padding-left: 5
    padding-right: 5
    layout: verticalBox
Did you add it here too?
edubart/otclient (https://github.com/edubart/otclient/blob/1addf3e1766ca3fe43bdf1114c0655a971123291/modules/game_interface/interface.otmod)
 
Solution
Back
Top