How to make users type on game?

Is there a condition/variable/object needed to make the user of the game possible to input their name/type anything on a certain area on the screen?

What I mean of type is the manual input of the player… not what the developer pre-made for them.

Yes, the “Text entry” object, search for it when adding a new object. You can de/activate the keyboard input through events, and get the currently saved string in it to, for example, display with a Text object :slight_smile:

I think there’s something wrong with my work. I was trying to toggle click and type (where if you click out of the text input, you can see the default text). Moreover, I cannot see the text I’m trying to input as well… with the font/text…

I wonder what’s wrong with the events I already set up there…

Not sure if it’s the only problem, but you want to activate the input when it’s active, and deactivate it when it’s inactive :wink:
Are you copying the text in memory of the Text Input into a Text object to disaplay it?
If it doesn’t work, please share your test (there is a “Upload attachment” button under the writing area while writing a post) to check it :slight_smile:

That’s exactly what I want to show on my game work (activate/deactive input). Hmmm… I’m not sure about the copying text stuff but I’ll upload it anyway. Welp… The file is too big, so the entire thing is in Google Drive (along with the misc files on it).

Here’s the link.

As you can check in the debugger, the text is saved in the memory of the AskQuery object:


You need a Text object to display it, with the action “Do = AskQuery.String() to the text of DisplayQuestionText”

By the way there is another error, as you can see in the debugger again:
Debug text 2.png
The expression in the event 7.1.1 :

"SubStr(TextEntry.String(), 10) to the text of TextEntry"

Should be:

SubStr(AskQuery.String(), 0, 10)

Note there are no quotes :wink:

Let me know if you get to solve it, otherwise I can send you a “patched” file, so you get an idea of how it works :slight_smile:

By the way here is a topic about using the Text Entry object: [url][Solved]how to use the text entry]

I don’t wanna necro on that linked topic but I’ll ask it here instead…
Well… That was I was trying to do. Instead of proceeding to next, I just want to keep the AskQuery intact and let the ask button in-game do the work of making the response for the Error Girl.


I just have questions regarding the images above (it can from the original linked topic actually)…

  1. Since the game I’m planning is like the Magic Eight Ball, how can I still retain the text if I clicked outside the Text Entry Object and reactivate the text entry when it is clicked?
  2. Does the text in the images above refer to the text object or the text entry object?
  3. How can I make the length of the character input in the text entry object be limitless? Was that by default or not?
  4. How can I apply the default font set on the text object to the text entry object?
  1. The string in memory of the Text Entry object is not “forgotten” by default, if you don’t do something like “Do = ’ ’ to the text in memory of AskQuery” the text will be kept in memory. You can show or hide this text through the Text object that displays the Text Entry object’s string.

  2. Text/text is a Text object that displays the Text Entry object’s string. The Text Entry can’t display text, it just get the keyboard input and save it in memory, then you read its string to work with/display it with a Text object.

  3. That is the default behavior (limitless), as you know, to limit the length you can use “SubStr(string, start, end)”.

  4. As the Text object is the object that displays the text, the font, color, size, etc. will be from the Text object, the Text Entry just give it the string saved in its memory.

The idea to get your system working should be:
Click inside text input area ===> Activate AskQuery
Click outside text input area ===> Deactivate AskQuery
Always or When any key is pressed ===> Copy the text of AskQuery to the TextDisplay object

I still can’t get into it… perhaps, I might be needing the patched work of it… so that I can get the concept of typing things up and how to toggle the click and other things that goes around.

Sure, it can be a bit difficult at first:
Ask Error girl.zip (921 KB)
Your project is lightweight, I have deleted the .psd files (really heavy and unnecessary), and now the zip file is under 1MB :wink:

My events are commented, let me know any question :slight_smile:

I somewhat get it now but the thing is… the text goes over the edge of the screen. I’m looking for a way to clip the characters when it exceeds the line.

First, you have to know how to detect if text the has exceeded the right limit, it happens when:

text.X() + text.Width() > Right edge

text.X() is the position of the text (its left edge position)
text.Width() is the width of the text, in pixels (it is not the length)
Right edge is the X position of the right limit of the writing area

Now, while the text exceed the limit, remove the last character (with SubStr), test the size, remove a character, test the size, and so on… until the text fits inside the writing area:


As I said, if you note low performance, use the last events (14 and 15). If so, you should put the While event as a sub-event of the event 14 :wink:

It still clips.

I followed the instructions above but it still clips… Below is shown how the objects are named and the events sequenced are programmed.

You have to test the position and width of the Text object (Question), no the Text Entry (AskQuery), the width of the AskQuery doesn’t get modified by the string it save… let me explain it :slight_smile:

  1. You activate AskQuery to save the string in its memory
  2. You get the string from the AskQuery and copy it inside the Question object, now Question has the string of AskQuery
  3. If the size of Question is too big, delete characters until it fits
  4. The string in the memory of AskQuery is not modified, just the string copied in Question

Checking your image, I don’t know how I didn’t realize that, instead modifying the string of the Question text object, modify the memory of the AskQuery would be a better option (no performance hit to reduce the string length if it’s too long), but you have to test the position and size with the Question object anyway, the idea would be:

  1. You activate AskQuery to save the string in its memory
  2. You get the string from the AskQuery and copy it inside the Question object, now Question has the string of AskQuery
  3. If the size of Question is too big, delete the last character from the memory of AskQuery, and update the text of Question too

Even you don’t need a “While” event, since you just delete the last character from the memory, a real “writing limiter”, check the event 12:
AskErrorGirl.zip (925 KB)

Man! You’re a lifesaver… Thanks!