check for input true/false?

Posted By: Siwler

check for input true/false? - 03/15/12 22:18

I need help guys, please.

How to check input's value if its true(oped the door) or false(do not open door, keep it shoot)

here is my code:
Code:
function display_controlP()

{
     while (key_enter) {wait (1);} // wait until the player releases the enter key
       str_cpy(Pcode_str, "#50"); // reset the input string
       inkey(Pcode_str); //  input control panels code
       reset (controlP_pan, SHOW); // and then let's hide the panel
       if (you == player)
       {
               my.event = NULL; // make the entity insensitive to other collisions with the player (for now)
               controlP_pan.flags |= (TRANSLUCENT | SHOW); // display the image
               while (vec_dist (player.x, my.x) < 100) {wait (1);} // wait until the player moves away from the entity
               my.event = display_controlP; // the entity is sensitive to impacts again
               controlP_pan.flags &= ~SHOW; // hide the image until the player collides with the entity again
       }

}


Posted By: Espér

Re: check for input true/false? - 03/15/12 22:21

give the door.skillXX a value of 1 (true) if itīs opened or 0 (false) if itīs closed...
and ask for that ._.
Posted By: Siwler

Re: check for input true/false? - 03/15/12 23:10

Hmm, I'm not shore that giving the door.skillXX a value of 1 (true) if itīs opened or 0 (false) if itīs closed... is something that I'm looking for.

Maybe I was not clear enough, let me try this again:

How do I scan for correct imputed value, for example:
Control panels correct value is 123 but if player enters 321 and presses enter key, door will not open, so player has to figure out the correct value which is 123 and enter 123 in to oped the door.

How do I code to scan for correct input value?
Posted By: lemming

Re: check for input true/false? - 03/16/12 07:55

Are you looking for str_cmp()?
Posted By: maslone1

Re: check for input true/false? - 03/16/12 08:05

@siwler

your answere is in your question
if you work with values a "if (value1 == value2) { check=true; } else {check = false; }" is enough
So it is that what Esper already wrote you.
Posted By: Wjbender

Re: check for input true/false? - 03/16/12 08:24

As i understand you want combination lock, on entering correct combination door opens rite? You could do this graphicly instead of keys .. Any one ever playd risen. Or could have 3 boxes that take one key input of numbers called a b c and compare to preset values d e f
Posted By: Siwler

Re: check for input true/false? - 03/16/12 21:07

Originally Posted By: lemming
Are you looking for str_cmp()?


Yes thank you, srt_cmp(); is what i was looking for.
I kind of needed example of how str_cmp worked,
I'll have a sting1 value preset inside the code and check inputted string2 value with string1 if its true/false.

Posted By: Widi

Re: check for input true/false? - 03/16/12 21:55

Quote:

I kind of needed example of how str_cmp worked


--> manual ?!!
Posted By: Siwler

Re: check for input true/false? - 03/16/12 22:25

Originally Posted By: Widi
Quote:

I kind of needed example of how str_cmp worked


--> manual ?!!


I love it when people leave pointless comments. laugh

I have a manual opened 24/7, if I fully understood how str_cmp worked for my complexity of code I wouldn't ask for any help.

But again any comment is appreciated and welcome here, Thank You Widi.

Remember I'm still new to coding, "Please" guys be patient with me.
Posted By: Widi

Re: check for input true/false? - 03/16/12 23:26

What do you not understand or find in the manual?
You have two strings as you said, string1 in your code with a given value and one for the inkey:

STRING* string1 = "1234";
STRING* string2 = "#4"; // String for the inkey
...

after the inkey you can compare this two strings:

if(str_cmp(string1,string2))
{
... // this code runs if string1 = string2
}

Posted By: Siwler

Re: check for input true/false? - 03/16/12 23:47

Thank you I figured that part out.

Now I can't activate door open code if when string1 == string2
Posted By: MrGuest

Re: check for input true/false? - 03/18/12 01:35

string1 will never = string2...

as you said earlier i love it when people answer the question with ... manual...
when you know where it is in the manual look it up... what would make Widi happy is people rephrasing their question to, 'Where in the manual can I find my answer to 'this''.

Look in the dictionary and work out how to spell Pneumonia... hopefully makes my point
Posted By: Siwler

Re: check for input true/false? - 03/18/12 20:35

Originally Posted By: MrGuest
string1 will never = string2...

as you said earlier i love it when people answer the question with ... manual...
when you know where it is in the manual look it up... what would make Widi happy is people rephrasing their question to, 'Where in the manual can I find my answer to 'this''.

Look in the dictionary and work out how to spell Pneumonia... hopefully makes my point


Lol, now it fails like people like to argue instead of helping out, interesting. laugh
© 2024 lite-C Forums