Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Send characters

Send characters

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Darkguard   (1 post)  Bio
Date Tue 09 Nov 2010 01:34 PM (UTC)
Message
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)


Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #1 on Tue 09 Nov 2010 03:54 PM (UTC)

Amended on Tue 26 Nov 2013 02:47 AM (UTC) by Nick Gammon

Message
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

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 09 Nov 2010 06:39 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #3 on Tue 09 Nov 2010 06:45 PM (UTC)
Message
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'))

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 09 Nov 2010 07:32 PM (UTC)

Amended on Tue 09 Nov 2010 07:33 PM (UTC) by Nick Gammon

Message
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. :)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #5 on Tue 09 Nov 2010 07:37 PM (UTC)
Message
Yep. Sorry, I wasn't arguing against you, I was explaining how both of our methods could be used together.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


18,408 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.