1 registered members (AbrahamR),
717
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
check for input true/false?
#397165
03/15/12 22:18
03/15/12 22:18
|
Joined: Nov 2009
Posts: 70
Siwler
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2009
Posts: 70
|
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:
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
}
}
Honesty will get you far, were dishonesty will get you only so far in life.
|
|
|
Re: check for input true/false?
[Re: Espér]
#397169
03/15/12 23:10
03/15/12 23:10
|
Joined: Nov 2009
Posts: 70
Siwler
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2009
Posts: 70
|
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?
Honesty will get you far, were dishonesty will get you only so far in life.
|
|
|
Re: check for input true/false?
[Re: lemming]
#397179
03/16/12 08:05
03/16/12 08:05
|
Joined: Jul 2007
Posts: 424 EUROPE
maslone1
Senior Member
|
Senior Member
Joined: Jul 2007
Posts: 424
EUROPE
|
@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.
A8c, Blender, FlStudio, Unity3d
|
|
|
Re: check for input true/false?
[Re: Siwler]
#397180
03/16/12 08:24
03/16/12 08:24
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
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
Compulsive compiler
|
|
|
Re: check for input true/false?
[Re: lemming]
#397246
03/16/12 21:07
03/16/12 21:07
|
Joined: Nov 2009
Posts: 70
Siwler
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2009
Posts: 70
|
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.
Honesty will get you far, were dishonesty will get you only so far in life.
|
|
|
Re: check for input true/false?
[Re: Siwler]
#397251
03/16/12 21:55
03/16/12 21:55
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
I kind of needed example of how str_cmp worked
--> manual ?!!
|
|
|
Re: check for input true/false?
[Re: Widi]
#397252
03/16/12 22:25
03/16/12 22:25
|
Joined: Nov 2009
Posts: 70
Siwler
OP
Junior Member
|
OP
Junior Member
Joined: Nov 2009
Posts: 70
|
I kind of needed example of how str_cmp worked
--> manual ?!! I love it when people leave pointless comments. 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.
Honesty will get you far, were dishonesty will get you only so far in life.
|
|
|
Re: check for input true/false?
[Re: Siwler]
#397254
03/16/12 23:26
03/16/12 23:26
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
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 }
Last edited by Widi; 03/16/12 23:28.
|
|
|
|