Send characters

Posted by Darkguard on Tue 09 Nov 2010 01:34 PM — 6 posts, 19,401 views.

#0
I need to send some special character to the mud for some specific fonctions ( CTRL+G and CTRL+O and some more...) Is there a way to go in a direct input mode where these commands would be sent ?

Trying to send those to the server I end up bringing some configuration panel locally and get stuck in a way that I have to disconnect from server because I cant send the (ctrl+whatever)


USA #1
If you can find out what the keys actually send - i.e. the ASCII character code - you can use that to create an accelerator that will send that character to the MUD. In this case, it seems likely that your terminal followed the caret-notation method (i.e. ctrl-A sends 1, ctrl-B sends 2, etc), so it's likely that you can just do this:
Accelerator("Ctrl+G", "\007")
Accelerator("Ctrl+O", "\015")


I created a function in Lua to more easily retrieve the caret-notation value of a letter:
function caret(chr)
  return string.char((chr):upper():byte() - ('@'):byte())
end

Accelerator("Ctrl+G", caret('G'))
Accelerator("Ctrl+O", caret('O'))


In order to add this code, you'll need a scripting file. There should be plenty of resources on how to create a scripting file at this point: search the forums, check the FAQ, etc. Nick also created a video tutorial for scripting: http://vimeo.com/80333485
Amended on Tue 26 Nov 2013 02:47 AM by Nick Gammon
Australia Forum Administrator #2
If this is something you just want to do inside an alias for some reason, you can just send it like this (with send-to-script):


Send (string.char (7))  -- send Ctrl+G


Ctrl+A is string.char (1), Ctrl+B is string.char (2) and so on.
USA #3
Nick Gammon said:
If this is something you just want to do inside an alias for some reason, you can just send it like this (with send-to-script):


Send (string.char (7))  -- send Ctrl+G


Ctrl+A is string.char (1), Ctrl+B is string.char (2) and so on.

And this is exactly what my above caret() function does, so it might be clearer and more self-evident to use that:
Send(caret('G'))
Australia Forum Administrator #4
Absolutely, but I was pointing out that in the event that he didn't want Ctrl+G as a keystroke to send Ctrl+G but merely have the functionality available (eg. you might type "menu" and have Ctrl+M sent) then merely doing a string.char would achieve that.

[EDIT]

So a combination of our approaches might be the best solution. :)
Amended on Tue 09 Nov 2010 07:33 PM by Nick Gammon
USA #5
Yep. Sorry, I wasn't arguing against you, I was explaining how both of our methods could be used together.