checking user's text input not working [RESOLVED]

tamercloud

  • Posts: 74
Hey guys,

I'm making a quiz type game, and I have to check if what the user types in is on a list of acceptable answers. The user's input is captured in the "Text" attribute, but when I use the if block that says "If (text) = (I use a text attribute with the answer written), then play bing sound.

However, it never enters the if loop, and I have no idea why. What am I doing wrong?

« Last Edit: July 11, 2013, 04:51:47 pm by tamercloud »

tgbtom

  • Posts: 127
It sounds like a pretty easy fix, however there's no way I can help unless you upload screenshots of behaviours so we can actually see what you might have done wrong! :P
________________,.-*'Renewal'*-.,________________
http://community.stencyl.com/index.php/topic,10615.0.html

http://renewalthegame.blogspot.ca/
------------------------'*-.,Renewal,.-*'------------------------

tamercloud

  • Posts: 74
It sounds like a pretty easy fix, however there's no way I can help unless you upload screenshots of behaviours so we can actually see what you might have done wrong! :P
Sure, I don't know why I haven't thought of simply doing that. Here goes. I downloaded the timer from stencylforge (by Luyren) and edited the section "if pressed key = ENTER" Text = test" where test is my test answer.


tgbtom

  • Posts: 127
I can't directly tell what the issue is, mainly because I don't know how most of this connects with other behaviours in the game. However a simple solution would be to put in print blocks in several spots to figure out where the code is going wrong...

I would suggest putting one inside the if "Enter was pressed" to determine if the game is actually processing that you are pressing Enter. Also try other spots. If you have anything more information to supply me with it may help me solve your issue :)

-Tgb
________________,.-*'Renewal'*-.,________________
http://community.stencyl.com/index.php/topic,10615.0.html

http://renewalthegame.blogspot.ca/
------------------------'*-.,Renewal,.-*'------------------------

tamercloud

  • Posts: 74
I can't directly tell what the issue is, mainly because I don't know how most of this connects with other behaviours in the game. However a simple solution would be to put in print blocks in several spots to figure out where the code is going wrong...

I would suggest putting one inside the if "Enter was pressed" to determine if the game is actually processing that you are pressing Enter. Also try other spots. If you have anything more information to supply me with it may help me solve your issue :)

-Tgb
If you were to download the timer from Stencylforge and edit the behavior on "text field behavior" under actor behaviors, that would be the one I'm editing.

I know it process enter being pressed because if I put the sound effect outside of the if loop, it works fine. I even did a draw of what it sets as "Text" once I press enter, and it shows exactly what I typed before hitting enter. That's why I'm so confused. It should be working.

tgbtom

  • Posts: 127
I will download the behaviour but what all was changed, and what was it changed to? I will do the same and tell you where you went wrong :P I hope! :)

-Tgb
________________,.-*'Renewal'*-.,________________
http://community.stencyl.com/index.php/topic,10615.0.html

http://renewalthegame.blogspot.ca/
------------------------'*-.,Renewal,.-*'------------------------

tamercloud

  • Posts: 74
I will download the behaviour but what all was changed, and what was it changed to? I will do the same and tell you where you went wrong :P I hope! :)

-Tgb
The only thing I changed was under "if pressed key = ENTER"

"if Text = test
play sound crowd"

that was it.

tgbtom

  • Posts: 127
Time Count by Luyren? That's the only thing I could find and I don't see at all what you posted in your screenshot? :S
________________,.-*'Renewal'*-.,________________
http://community.stencyl.com/index.php/topic,10615.0.html

http://renewalthegame.blogspot.ca/
------------------------'*-.,Renewal,.-*'------------------------

tamercloud

  • Posts: 74
Time Count by Luyren? That's the only thing I could find and I don't see at all what you posted in your screenshot? :S
yes, that's it. Here is a repost of the picture and I circled what I added in.

tgbtom

  • Posts: 127
Must have different stencyl versions. OK here is how you should be able to fix it though. In the when Enter was pressed block put a block just like what I have attached. IF you do this exactly then check what the debugger outputs when you press enter, and see if they are what you want them to be. Keep in mind there may be a space in one of them which would cause them to not be the same thing.

-Tgb
________________,.-*'Renewal'*-.,________________
http://community.stencyl.com/index.php/topic,10615.0.html

http://renewalthegame.blogspot.ca/
------------------------'*-.,Renewal,.-*'------------------------

tamercloud

  • Posts: 74
WOAH I just figured it out! When I entered the box it automatically puts a space in there, so that's why it was never being picked up!

tamercloud

  • Posts: 74
Must have different stencyl versions. OK here is how you should be able to fix it though. In the when Enter was pressed block put a block just like what I have attached. IF you do this exactly then check what the debugger outputs when you press enter, and see if they are what you want them to be. Keep in mind there may be a space in one of them which would cause them to not be the same thing.

-Tgb
Thanks for the help, though. I probably would not have seen this had I not gone through the code again to show you.

tgbtom

  • Posts: 127
Aha well I tried ^_^ Glad you found what was wrong!
________________,.-*'Renewal'*-.,________________
http://community.stencyl.com/index.php/topic,10615.0.html

http://renewalthegame.blogspot.ca/
------------------------'*-.,Renewal,.-*'------------------------