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

WASD Mode on OtClient

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
57
I'm trying to put to activate the "WASD Mode" when you go Ctrl+F, and disable when go Ctrl+F again. But something is wrong.. What I'm doing wrong?

I can only disable the WASD mode with Ctrl + F.. But I can't activate it with Ctrl + F :(

Console.lua
Lua:
function toggleChat()
  if consoleToggleChat:isChecked() then
    disableChat()
  else
    enableChat()
  end
end

function enableChat()
  local gameInterface = modules.game_interface

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

  local quickFunc = function()
    if consoleToggleChat:isChecked(false) then
      consoleToggleChat:setChecked()
    end
    disableChat()
  end
  g_keyboard.unbindKeyUp('CTRL+F', quickFunc)

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

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

  consoleToggleChat:setTooltip(tr("Disable fight mode (Ctrl+F)."))
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('CTRL+F', 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)

  consoleToggleChat:setTooltip(tr("Enable fight mode (Ctrl+F)."))
end
 
This worked for me.

Add this function:
Lua:
function hotkeyToggleChat()
  consoleToggleChat:setChecked(not consoleToggleChat:isChecked())
  if consoleToggleChat:isChecked() then
    disableChat()
  else
    enableChat()
  end
end
Then in init() where the other key bindings are, add this: g_keyboard.bindKeyPress('CTRL+F', hotkeyToggleChat)
That is all you need, you can remove the stuff you added in enableChat/disableChat.
 
This worked for me.

Add this function:
Lua:
function hotkeyToggleChat()
  consoleToggleChat:setChecked(not consoleToggleChat:isChecked())
  if consoleToggleChat:isChecked() then
    disableChat()
  else
    enableChat()
  end
end
Then in init() where the other key bindings are, add this: g_keyboard.bindKeyPress('CTRL+F', hotkeyToggleChat)
That is all you need, you can remove the stuff you added in enableChat/disableChat.

Like this ? Because don't work :(
Console.lua
Lua:
function hotkeyToggleChat()
  consoleToggleChat:setChecked(not consoleToggleChat:isChecked())
  if consoleToggleChat:isChecked() then
    disableChat()
  else
    enableChat()
  end
end

function enableChat()
  local gameInterface = modules.game_interface

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

  local quickFunc = function()
    if consoleToggleChat:isChecked(false) then
      consoleToggleChat:setChecked()
    end
    disableChat()
  end
  g_keyboard.bindKeyUp('CTRL+F', quickFunc)

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

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

  consoleToggleChat:setTooltip(tr("Disable fight mode (Ctrl+F)."))
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('CTRL+F', 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)

  consoleToggleChat:setTooltip(tr("Enable fight mode (Ctrl+F)."))
end

Init,lua
Lua:
-- Fight Mode
g_keyboard.bindKeyPress('CTRL+F', hotkeyToggleChat)
 
Not init.lua, in the function init in console.lua, and remove quickFunc and the bindKeyUp from the enableChat and disableChat functions.
 
How can I turn this button on using a button on another module?

Example, I have a Module_Actions, and inside have a button Fight Mode. How can this button activate the Ctrl F ?

I tried this, but don't work:
Actions.otui
Code:
    CheckBox2
      id: toggleChat
      !text: tr('Fightmode')
      font: verdana-11px-rounded
      color: #c8c8c8
      size: 74 20
      anchors.top: insidewindow2.top
      anchors.left: chaseModeBox.right
      anchors.right: insidewindow2.right
      margin-top: 1
      margin-left: 1
      margin-right: 1
      @onCheckChange: modules.game_console.toggleChat()
 
Back
Top