ID:1103195
 
(See the best response by Jemai1.)
I'm curious as to how you make an input box enabled only when you press a certain key. Also, how do you have the executed command affected by key press?
Use a keyboard library, like forum_account's keyboard lib

Then

mob
key_down(k, client/c)
if(k == "return")
//show
verb/say(t as text)
DoMessageCode(t)
//hide


//to show
winset(client, "window.control", "is-visible=true;focus=true")
winset(client, "window.control", "text=say \"")

//to hide
winset(client, "window.control", "is-visible=false;focus=false")
winset(client, "window.map1", "focus=true")


So user presses enter, and input is made visible and focused... next the user types text, it appears in the input box, user hits enter. This executes the say verb which will say the message and return the focus back to the map and make the input box invisible again.

There's only one problem with this, there's no escape hook to cancel the say if the user doesn't want to say anything. I'm not sure if there's a way to do that.
In response to FIREking
FIREking wrote:

There's only one problem with this, there's no escape hook to cancel the say if the user doesn't want to say anything. I'm not sure if there's a way to do that.

It's super simple to hide the chat box if nothing is there. Just check to see if the argument is false; Meaning nothing was entered.

 mob
key_down(k, client/c)
if(k == "return")
//show
verb/say(t as text)
if(!t)
//hide
else
DoMessageCode(t)
//hide
In response to Lavitiz
Lavitiz wrote:
FIREking wrote:

There's only one problem with this, there's no escape hook to cancel the say if the user doesn't want to say anything. I'm not sure if there's a way to do that.

It's super simple to hide the chat box if nothing is there. Just check to see if the argument is false; Meaning nothing was entered.

>  mob
> key_down(k, client/c)
> if(k == "return")
> //show
> verb/say(t as text)
> if(!t)
> //hide
> else
> DoMessageCode(t)
> //hide
>


No, by the time you've switched focus to the input control, your cursor is in the input box, and pressing escape will do nothing. Yeah, you can let the person type in a null message and bypass that, but that's not super intuitive. Most pc games would have you hit escape to back out of the say / command
Another problem, I don't think starting a separate thread is ideal. I have 3 buttons, each of them change the chat command. However, none of them are working.

Here is the format for each of them:

.winset(usr,"window1.chat","command="OOC"")
change command to text

and if you're trying to change "command-text", that's just a variable on the client.

also, you need \" to represent a quote in between two quotes

"say \""
Everytime I add a \, the program automatically deletes it...
In response to BeignetLover
To place a quote inside a string, escape it with \. It is not adding \ to the string, you just escaped " in order to place it inside the string.

"\"" will be a string containing just the " character.
.winset(usr,"window1.chat","text=Say \"")

I put the \ there, but it simply disappears everytime I look at it again.
Yes. \ is not supposed to show. That's what escaping is about.

\" is a single character representing "

You do that to differentiate it from your opening and closing quotes.
Regardless, whenever my line as a command for my buttons, it doesn't work. Do you think I should replace it with a verb that has a null category?
Best response
It should be
winset(usr,"window1.chat","command=\"Say\"")
without the period on winset.

If you want Say to be visible, add a !, i.e.
winset(usr,"window1.chat","command=\"!Say\"")


You can avoid depending on verbs by using .winset as a command for your button.
Go to your skin, edit the button then set the command
.winset "window1.chat.command=\"!Say\""
Thank you so much! This actually worked.