by Slasher » Sat Jul 12, 2008 1:26 pm
The idea of this was to allow the player to actually type in a number or, if possible, a string, rather than having to fake some weird way of creating separate variables for each digit, and then checking for the proper digit in the proper place.
I realize that direct keyboard input is not something Doom was designed for, and therefore would have to be seriously thought about before being implemented. However, normal programming has ways to protect against the problems that come with people inputting invalid data. Scripts using this should handle it as well.
Code: Select all
Script 1 (void) // This script is activated by pressing on a line, with a keypad texture. It asks for the password, and opens the door if correct.
{
int number;
Print(s:"Please enter the password."); // A message is displayed, telling the player to expect an input prompt.
number=InputValue(number); // The input prompt. Unless it becomes customizable, I'm thinking it would look like the in-game chatting messages when you press T.
// I'm starting to prefer the name InputValue()
if(number != 4532)) // This hopefully covers everything except the correct password.
{
Print(s:"Incorrect password!"); // Let them know it was wrong, or invalid.
ACS_Terminate(1,0); // Password was wrong, door doesn't open. Maybe an alarm could start at this point. Up to the modder.
}
else // Player inputs the correct password
{
// The door opening stuff
}
}
Here is an excellent example of where someone could use this. Now in this script, getting the correct input, or any input at all, isn't of dire importance the first time around. The number does not have to be correct before leaving the script. In a script where it would be necessary, some looping would be involved, but anybody who knows even basic C input/output commands knows how to do that, and for people who don't know that stuff, it wouldn't be too hard to learn this.
As for starting an input prompt while being attacked by monsters, there are different ways this could be handled, which are decisions to be made by the modder. Since this will take the keystrokes of moving the player as input, the player will have to be pressing nothing else, and therefore essentially frozen in place. So I would have monsters frozen the same way. Use the freeze power up, with a small duration, and give them to all enemies on the map, and repeat this while the script waits for your input. Once it receives your input, it will stop delaying, and stop giving out the freeze powerup. This then resumes the normal behavior, and continues on.
This freeze powerup idea has probably been used before by modders, for other things. I don't see why it couldn't be used here, to protect the player from getting hurt. And if it's multiplayer, the other players could protect someone while he's busy inputting, just like the new co-op Strife behavior.
The idea of this was to allow the player to actually type in a number or, if possible, a string, rather than having to fake some weird way of creating separate variables for each digit, and then checking for the proper digit in the proper place.
I realize that direct keyboard input is not something Doom was designed for, and therefore would have to be seriously thought about before being implemented. However, normal programming has ways to protect against the problems that come with people inputting invalid data. Scripts using this should handle it as well.
[code]Script 1 (void) // This script is activated by pressing on a line, with a keypad texture. It asks for the password, and opens the door if correct.
{
int number;
Print(s:"Please enter the password."); // A message is displayed, telling the player to expect an input prompt.
number=InputValue(number); // The input prompt. Unless it becomes customizable, I'm thinking it would look like the in-game chatting messages when you press T.
// I'm starting to prefer the name InputValue()
if(number != 4532)) // This hopefully covers everything except the correct password.
{
Print(s:"Incorrect password!"); // Let them know it was wrong, or invalid.
ACS_Terminate(1,0); // Password was wrong, door doesn't open. Maybe an alarm could start at this point. Up to the modder.
}
else // Player inputs the correct password
{
// The door opening stuff
}
}[/code]
Here is an excellent example of where someone could use this. Now in this script, getting the correct input, or any input at all, isn't of dire importance the first time around. The number does not have to be correct before leaving the script. In a script where it would be necessary, some looping would be involved, but anybody who knows even basic C input/output commands knows how to do that, and for people who don't know that stuff, it wouldn't be too hard to learn this.
As for starting an input prompt while being attacked by monsters, there are different ways this could be handled, which are decisions to be made by the modder. Since this will take the keystrokes of moving the player as input, the player will have to be pressing nothing else, and therefore essentially frozen in place. So I would have monsters frozen the same way. Use the freeze power up, with a small duration, and give them to all enemies on the map, and repeat this while the script waits for your input. Once it receives your input, it will stop delaying, and stop giving out the freeze powerup. This then resumes the normal behavior, and continues on.
This freeze powerup idea has probably been used before by modders, for other things. I don't see why it couldn't be used here, to protect the player from getting hurt. And if it's multiplayer, the other players could protect someone while he's busy inputting, just like the new co-op Strife behavior.