Itutorial
Excellent OT User
- Joined
- Dec 23, 2014
- Messages
- 2,324
- Solutions
- 68
- Reaction score
- 998
So I am trying to make it so players use WASD walking always. The chat box should activate by pressing enter.
I can't figure out how to get it so when I press enter the chatbox is enabled and if I press it again (even with no text) it will disable.
Any help would be great.
I tried adding
to disableChat() function but it automatically enables the chat because I press it to send the message.
Figured it out. Just add
console.lua
and add
under
I can't figure out how to get it so when I press enter the chatbox is enabled and if I press it again (even with no text) it will disable.
Any help would be great.
Lua:
function enableChat()
local gameInterface = modules.game_interface
consoleTextEdit:setVisible(true)
consoleTextEdit:setText("")
g_keyboard.unbindKeyUp("Space")
g_keyboard.unbindKeyUp("Enter")
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")
consoleToggleChat:setTooltip(tr("Disable chat mode, allow to walk using ASDW"))
end
function disableChat()
local gameInterface = modules.game_interface
consoleTextEdit:setVisible(false)
consoleTextEdit:setText("")
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)
consoleToggleChat:setTooltip(tr("Enable chat mode"))
end
function sendCurrentMessage()
local message = consoleTextEdit:getText()
if #message == 0 then return end
consoleTextEdit:clearText()
-- send message
sendMessage(message)
consoleToggleChat:setChecked(true)
disableChat()
end
I tried adding
Lua:
g_keyboard.bindKeyPress("Enter", enableChat())
Post automatically merged:
Figured it out. Just add
console.lua
Lua:
function newToggle()
if consoleToggleChat:isChecked() then
consoleToggleChat:setChecked(false)
enableChat()
else
consoleToggleChat:setChecked(true)
disableChat()
end
end
and add
Lua:
g_keyboard.bindKeyUp('Enter', newToggle, consolePanel)
under
Lua:
g_keyboard.bindKeyDown('Enter', sendCurrentMessage, consolePanel)
Last edited: