Be a Supporter!

Text based game input help

  • 343 Views
  • 10 Replies
New Topic Respond to this Topic
Frankmank
Frankmank
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Text based game input help 2009-02-22 18:55:11 Reply

I've got the input text where you type in the command you want to try, and then the dynamic text box which displays what you just typed in, the problem is it does it immediately, I'd like to have it so it displays after hitting enter and then clear the input text field, I don't use input text fields ever so i'm looking for some pointers.


BBS Signature
Sam
Sam
  • Member since: Oct. 1, 2005
  • Offline.
Forum Stats
Moderator
Level 19
Programmer
Response to Text based game input help 2009-02-22 19:02:40 Reply

So youd enter the command into this textbox with the var "input".

On the frame have something like:

onLoad = function(){
input = ""
}

onEnterFrame = function(){
if(Key.isDown(Key.ENTER)){
if(input=="COMMAND"){
gotoAndPlay(2);
}
}
}
Frankmank
Frankmank
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Text based game input help 2009-02-22 23:34:54 Reply

At 2/22/09 07:02 PM, Saza wrote: So youd enter the command into this textbox with the var "input".

On the frame have something like:

onLoad = function(){
input = ""
}

onEnterFrame = function(){
if(Key.isDown(Key.ENTER)){
if(input=="COMMAND"){
gotoAndPlay(2);
}
}
}

It does exactly as it did before, as I type in the input text it instantly is shown in the dynamic text box as I type it, I want it so the dynamic text box is empty until I hit enter in the input, which is then sent to the dynamic text box


BBS Signature
Frankmank
Frankmank
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Text based game input help 2009-02-23 08:38:41 Reply

bump


BBS Signature
Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Text based game input help 2009-02-23 09:58:28 Reply

Change the input textbox var to inTxt and the dynamic textbox var to dynTxt

Add this to the main timeline

kl=new Object();
kl.onKeyDown=function(){
	if(Key.getCode()==13){  //ENTER
		dynTxt=inTxt;
	}
}
Key.addListener(kl);

- - Flash - Music - Images - -

BBS Signature
Frankmank
Frankmank
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Text based game input help 2009-02-23 19:30:05 Reply

At 2/23/09 09:58 AM, Denvish wrote: Change the input textbox var to inTxt and the dynamic textbox var to dynTxt

Add this to the main timeline

kl=new Object();
kl.onKeyDown=function(){
if(Key.getCode()==13){ //ENTER
dynTxt=inTxt;
}
}
Key.addListener(kl);

Thanks, it works perfectly except for clearing the input box but I fixed that easily enough.

Now I wondering which is the most efficient way of checking the answers put into the input box arrays or what? all the coding I do is checking variables against each other and that might get too bulky for this game.


BBS Signature
Frankmank
Frankmank
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Text based game input help 2009-02-23 20:41:43 Reply

Also I'm wondering how to check the commands inputted, because as I have it set up now it doesn't seem to be working.

onEnterFrame=function(){
	if (dynTxt == "play"){
		nextFrame();
}};

BBS Signature
Frankmank
Frankmank
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Text based game input help 2009-02-23 23:15:11 Reply

Come on, this can't be a difficult question.


BBS Signature
BillysProgrammer
BillysProgrammer
  • Member since: Sep. 17, 2008
  • Offline.
Forum Stats
Member
Level 16
Gamer
Response to Text based game input help 2009-02-24 00:42:20 Reply

if not, then you do it :P

var dynText = inputtextinstancename.text;

onEnterFrame = function() {
     if(dynText == "play") {
          //bah
     }
}
Frankmank
Frankmank
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to Text based game input help 2009-02-24 20:31:55 Reply

At 2/24/09 12:42 AM, BillysProgrammer wrote: if not, then you do it :P

var dynText = inputtextinstancename.text;

onEnterFrame = function() {
if(dynText == "play") {
//bah
}
}

Ouch, well as I said I don't have any experience with text boxes besides displaying variables.

Anyhoo, that doesn't seem to work,

onEnterFrame=function(){
	if (dynTxt("play")){
		trace("working")
		nextFrame();
}}

BBS Signature
BillysProgrammer
BillysProgrammer
  • Member since: Sep. 17, 2008
  • Offline.
Forum Stats
Member
Level 16
Gamer
Response to Text based game input help 2009-02-24 20:43:08 Reply

Now you have it as a function. When you do blah() its a function or your working with OOP (object oriented program) and so far its a no..

Learn to use google man...

"Checking input text in flash actionscript 2.0"