How do I Save text in a variable from a text object

Get help using Construct 2

Post » Thu Jul 23, 2015 7:06 pm

i have two boxes to test, when i type with my keyboard then in the first sprite box appear the word that i wrote and in the second box my game shows the same word but in a text object, i am trying to save in a variable the word of any of the two boxes without success, after researching i cant found the answer, please help.

i tried this:

keyboard (on key code 13 pressed) -> TextObject (set mywords to TextObject.text)

in the debugger mode the variable value of mywords is 0, if i write some text in the default text value after pressing the key enter the value is set to 0, i dont understand why the word cant be saved.
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Thu Jul 23, 2015 7:25 pm

Perhaps have you set "myword" to Global number instead of Global text?
Image Image
B
26
S
15
G
142
Posts: 881
Reputation: 74,060

Post » Thu Jul 23, 2015 7:29 pm

MadSpy wrote:Perhaps have you set "myword" to Global number instead of Global text?

its an instance variable type text, i am trying now with a global text with an initial value , when i hit Enter the value of the variable is empty.
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Thu Jul 23, 2015 7:43 pm

Is the code "keyboard (on key code 13 pressed) -> TextObject set text to TextBox.text" works?
Image Image
B
26
S
15
G
142
Posts: 881
Reputation: 74,060

Post » Thu Jul 23, 2015 7:51 pm

MadSpy wrote:Is the code "keyboard (on key code 13 pressed) -> TextObject set text to TextBox.text" works?

didn't work, i dont know why, in the text object properties obviously "Text" is empty, and the game set the variable with an "empty value" too, this have sense, then my question is how i can save in a variable the typed text of the text object.
Last edited by Majinboo on Thu Jul 23, 2015 7:55 pm, edited 1 time in total.
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Thu Jul 23, 2015 7:52 pm

Could you share your capx or a screenshot of your code?
Image Image
B
26
S
15
G
142
Posts: 881
Reputation: 74,060

Post » Thu Jul 23, 2015 8:10 pm

MadSpy wrote:Could you share your capx or a screenshot of your code?

thanks for your help, Now its working, i dont know why but this cant work with sprite fonts or saved letters in an array, the solution was put the same words in an invisible textobject without spritefont or letters saved in an array.
B
9
S
3
Posts: 142
Reputation: 1,108


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests