How to save nicknames as strings and send them directly to the game manager(through hash)

#1

Hello!
I want to save the user name as a string and send it to the game manager.
Type the user name, press the keyboard enter button, and it’ll be sent to the game manager.
But… I’ve looked up a lot of data, but I don’t know how to do
I’m working really hard, but I don’t know well.:disappointed_relieved:
Can you help me?


0 Likes

#2

Where are you currently stuck? Can you type in the username in the input field?

0 Likes

#3

Yes, I can type in the username in the input field

0 Likes

#4

Ok, great! So next step then is to:

Is the game manager in some other script? You can send it using a message:

function on_input(self, action_id, action)
    self.username = dirtylarry:input(...
    dirtylarry:button("send_username_button_id", action_id, action, function ()
        -- send the username when the button is clicked
        msg.post("url to game manager", "username", { username = self.username })
    end)
end
0 Likes

#5

Oh, Thank you very much:smile:
yes, game manager is in other script!
so, I will make nwe button?
or Can I just press the Enter key to send it?

0 Likes

#6

If you want the user to press a button to send the username then yes, you need to create a button.

Sure. Add a key binding for KEY_ENTER and when you detect a press of that key in your on_input() function you send the message containing the username.

0 Likes

#7

Thank you so much!!!
:blush::blush:

0 Likes