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

Mod to disable chat after sending a message

specail

New Member
Joined
Oct 13, 2020
Messages
4
Reaction score
0
So I looked everywhere on google and here on the forums and couldn't find any topic like this.
I want to know if it's possible to create a mod that will disable chat after a message is sent (after pressing enter), or just by pressing enter without any text at all.
It just feels weird to be able to enable chat with Enter, but when wanting to disable it I have to manually click the checkbox at the bottom left corner :s
 
Yes, you can customize the chat behavior in
I suppose it's in 'function disableChat()' but what exactly do I have to change? Sorry I'm really new to this.
Here's how mine looks like:

Lua:
function disableChat()
  local gameInterface = modules.game_interface

  consoleTextEdit:setVisible(false)
  consoleTextEdit:setText("")

  local quickFunc = function()
    if consoleToggleChat:isChecked() then
      consoleToggleChat:setChecked(false)
    end
    enableChat()
  end
  g_keyboard.bindKeyUp("Enter", quickFunc)
  g_keyboard.bindKeyUp("Escape", quickFunc)

  gameInterface.bindWalkKey("W", North)
  gameInterface.bindWalkKey("D", East)
  gameInterface.bindWalkKey("S", South)
  gameInterface.bindWalkKey("A", West)

  gameInterface.bindWalkKey("E", NorthEast)
  gameInterface.bindWalkKey("Q", NorthWest)
  gameInterface.bindWalkKey("C", SouthEast)
  gameInterface.bindWalkKey("Z", SouthWest)
 
  g_keyboard.bindKeyPress('Ctrl+W', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+D', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+S', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+A', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)

  g_keyboard.bindKeyPress('Space', chooseAimFromBattleList)

  consoleToggleChat:setTooltip(tr("Enable chat mode"))
end
 
Last edited:
So I was able to create a hotkey to disable chat and it looks like this:
Lua:
function toggleChat()
  if consoleToggleChat:isChecked() then
    disableChat()
  else
    enableChat()
  end
  g_keyboard.bindKeyDown('Ctrl+F', disableChat)
end

However I found 2 issues:
1) when I press the hotkey, chat is disabled as expected, however the togglechat checkbox remains unchecked.
2) sometimes when logging in the hotkey will not work untill I send some messages, or manually click the togglechat checkbox a few times.

Issue 1 is just a visual nuisance as far as I know, but issue 2 might lead players to some headache if their hotkeys/chat don't work properly when they need to...
 
It works, for me.

Lua:
function enableChat()
  local gameInterface = modules.game_interface

  consoleTextEdit:setVisible(true)
  --consoleTextEdit:setText("")

  --g_keyboard.unbindKeyUp("Space")
  g_keyboard.unbindKeyUp("Enter")
  if consoleToggleChat:isChecked() then
    g_keyboard.bindKeyUp("Enter", disableChat)
  end
  --g_keyboard.unbindKeyUp("Escape")

  gameInterface.unbindWalkKey("W")
  gameInterface.unbindWalkKey("D")
  gameInterface.unbindWalkKey("S")
  gameInterface.unbindWalkKey("A")

  gameInterface.unbindWalkKey("E")
  gameInterface.unbindWalkKey("Q")
  gameInterface.unbindWalkKey("C")
  gameInterface.unbindWalkKey("Z")

  g_keyboard.unbindKeyPress('Ctrl+W', gameRootPanel)
  g_keyboard.unbindKeyPress('Ctrl+D', gameRootPanel)
  g_keyboard.unbindKeyPress('Ctrl+S', gameRootPanel)
  g_keyboard.unbindKeyPress('Ctrl+A', gameRootPanel)

  consoleToggleChat:setTooltip(tr("Disable chat mode, allow to walk using WSAD"))
end

function disableChat()
  local gameInterface = modules.game_interface

  consoleTextEdit:setVisible(false)
  --consoleTextEdit:setText("")

  local quickFunc = function()
    if consoleToggleChat:isChecked() then
      --consoleToggleChat:setChecked(false)
    end
    enableChat()
  end
 -- g_keyboard.bindKeyUp("Space", quickFunc)
  g_keyboard.bindKeyUp("Enter", quickFunc)
 -- g_keyboard.bindKeyUp("Escape", quickFunc)

  gameInterface.bindWalkKey("W", North)
  gameInterface.bindWalkKey("D", East)
  gameInterface.bindWalkKey("S", South)
  gameInterface.bindWalkKey("A", West)

  gameInterface.bindWalkKey("E", NorthEast)
  gameInterface.bindWalkKey("Q", NorthWest)
  gameInterface.bindWalkKey("C", SouthEast)
  gameInterface.bindWalkKey("Z", SouthWest)

  g_keyboard.bindKeyPress('Ctrl+W', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+D', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+S', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+A', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)

  consoleToggleChat:setTooltip(tr("Enable chat mode"))
end
 
Back
Top