• 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!

Lua ConsoleToggleChat a nil value

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
58
I create a button in other module, to connect with my Console module, but I can't make this work..

The line 170 is " if consoleToggleChat:isChecked() then"

I get this error on my OtClient


Code:
ERROR: protected lua call failed: LUA ERROR:
/game_console/console.lua:170: attempt to index global 'consoleToggleChat' (a nil value)
stack traceback:
    [C]: in function '__index'
    /game_console/console.lua:170: in function 'toggleChat'
    /game_actions/actions.otui:69: [@onCheckChange]:2: in function </game_actions/actions.otui:69: [@onCheckChange]:1>
    [C]: in function 'setChecked'
    /corelib/ui/uicheckbox.lua:12: in function </corelib/ui/uicheckbox.lua:11>

console.lua

Lua:
function init()
  consoleToggleChat = modules.game_actions.actionsWindow:getChildById('button30')
end

function toggleChat()
  if consoleToggleChat:isChecked() then
    disableChat()
  else
    enableChat()
  end
end

actions.otui

CSS:
MiniWindow
  id: actionsWindow
  !text: tr('Actions')
  height: 197
  width: 165

  MiniWindowContents
    CheckBox2
      id: button30
      !text: tr('Fightmode')
      font: verdana-11px-rounded
      color: #c8c8c8
      size: 74 20
      anchors.top: insidewindow2.top
      anchors.left: button3.right
      anchors.right: insidewindow2.right
      margin-top: 1
      margin-left: 1
      margin-right: 1
      @onCheckChange: modules.game_console.toggleChat()
 
Last edited:
Do you have in your module definitions file - actions.otmod - this line?

@onLoad: init()

It should look like this:
Screenshot

This not works, my otmod is like ur otmod.

CSS:
Module
  name: game_actions
  description: Manage actions window
  author: Helliot
  website: http://www.thelastempire.net
  sandboxed: true
  autoload: true
  autoload-priority: 1000
  scripts: [ actions ]
  @onLoad: init()
  @onUnload: terminate()
 

Similar threads

Replies
0
Views
337
Back
Top