[ACS] GetValue Function

Moderator: GZDoom Developers

User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

[ACS] GetValue Function

Post by Slasher »

Ok, I don't know if this is possible, although it seems like it should be simple enough. Again I don't really know.

Here it is: GetValue(int variable)

Really simple use for this feature: Input the value for a variable, just like any simple program that accepts standard keyboard input.

Would be useful for countless ideas. For example:

Code: Select all

Script 1 (void)
{
   int number;
   number=GetValue(number); // this would then allow the player to type in "6521" or something. Up to the devs how that should be taken care of, if they like this idea.
}
This would make things like code doors, selecting choices, and many others things super easy.

Currently, the only way I can think of inputting the value of a variable manually is to have each digit a separate value in an array, and then somehow parse them into one variable. This would make all that really easy.

Another use, for strings possibly. CIF3 uses a complicated ACS script that allows the player to input their name. With this feature, you could simply type it in when prompted. (About being prompted, I think Hudmessage() or Print() should be able to handle that. This function should only need to handle the input.)

So is this doable? Anyone else like this idea?

EDIT: On second thought, maybe InputValue() would be a better name.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: [ACS] GetValue Function

Post by HotWax »

Something tells me the devs aren't going to be too keen to add an input prompt directly into the game...
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [ACS] GetValue Function

Post by Slasher »

HotWax wrote:Something tells me the devs aren't going to be too keen to add an input prompt directly into the game...
Why not?

I figure it should be very similar to the in-game chatting messages, like when you press T and type a message. Then it somehow inputs the value into the variable.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: [ACS] GetValue Function

Post by Gez »

An input function always take a string (because the player can type anything), and ACS doesn't do string manipulation.

What do you do if when prompted for a number the player types "five" just to be a smartass? Crash the computer? Return 0? Return the ASCII code value (1718187621 if you want to know)? What if he types enter directly without typing anything? And so on.
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [ACS] GetValue Function

Post by Slasher »

Gez wrote:What do you do if when prompted for a number the player types "five" just to be a smartass? Crash the computer? Return 0? Return the ASCII code value (1718187621 if you want to know)? What if he types enter directly without typing anything? And so on.
The same way normal programming would protect from those things. If you type "five", ACS should know that's not an integer, and any script using this should be made to display an appropriate message. Why would it crash? If nothing is entered, the variable is defaulted to 0 anyway, so nothing would change.

I'm sure there are ways the devs can keep it from crashing.

It'll probably get NO'ed, but I figured it couldn't hurt to suggest it.
User avatar
Enjay
 
 
Posts: 27140
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: [ACS] GetValue Function

Post by Enjay »

Slasher wrote:It'll probably get NO'ed
I'm pretty sure that it has been asked about in the past and got NO'd. Possibly due to a technical limitation of ACS or something?
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: [ACS] GetValue Function

Post by Gez »

I don't think ACS is a good language for such a feature anyway. In other words, it's a job for the ever-elusive DoomScript.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: [ACS] GetValue Function

Post by HotWax »

The problem I see with this is how it is presented to the user. Typically when a program needs input -- and it's not content to just read one key at a time from the keyboard buffer -- it displays a prompt and waits for the user to type something and hit Enter, then retreives the input and stores it in a variable. How do you translate that to a real-time FPS? When this command is reached, do you suddenly pause the game on the player to display a prompt? Bring the console down (having the same effect)? What if the user is pressing Enter for some reason at that point in the game?

Any way you look at this you'd be creating a command that forcibly interrupts the game. Sure, if it's used properly this wouldn't matter because the player would be expecting the prompt, I suppose (like in response to pressing Use on a keypad or something), but there're few ways to be 100% certain the player hasn't dragged some monsters into the room and activated the script by mistake...
User avatar
MartinHowe
Posts: 2089
Joined: Mon Aug 11, 2003 1:50 pm
Preferred Pronouns: He/Him
Location: East Suffolk (UK)

Re: [ACS] GetValue Function

Post by MartinHowe »

Given that conversations scripts in Strife exist, getting a number from the player at runtime shouldn't be that hard theoretically.

As for strings, they work in ACS much like those of .NET - except that in ACS the engine cannot create new ones dynamically because the string table in a script has a fixed size. There's no theoretical reason, especially now that ZDoom has garbage collection, why ACS couldn't have run-time string support, but there'd be an awful lot of i's to dot and t's to cross in order to actually do it.

Hey, forget DoomScript, let's have Randy study the Mono project and have ZDoom include the .NET Compact Framework and use C# instead :P
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [ACS] GetValue Function

Post by Slasher »

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.
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: [ACS] GetValue Function

Post by Xaser »

MartinHowe wrote:...have ZDoom include the .NET Compact Framework...
Oh, dear. Assuming the quick addition of 'compact' doesn't change the usual meaning much, this would spell the death of ZDoom for me, considering that I cannot, under any circumstances download+install WinXP-SP2 or .NET Framework thanks to my dialup connection and Microsoft's genius decision to drop any shape or form of a 'resume download' feature using Windows Update.

Well I could order a CD and stuff but why bother? Protest, mate. ;P
User avatar
Isle
Posts: 687
Joined: Fri Nov 21, 2003 1:30 am
Location: Arizona, USA

Re: [ACS] GetValue Function

Post by Isle »

User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [ACS] GetValue Function

Post by Slasher »

You have not implemented a direct keyboard input prompt function.

What you did is really complicated and I have trouble understanding it, let alone replicating it.
User avatar
Isle
Posts: 687
Joined: Fri Nov 21, 2003 1:30 am
Location: Arizona, USA

Re: [ACS] GetValue Function

Post by Isle »

does the kyboard numberpad count?
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: [ACS] GetValue Function

Post by Slasher »

It's a way to create a keypad, but it's complicated and people who would want to look at it so they learn how to use it, get confused. I do, at least. The keypad was only a simple example I created on the fly.

This feature suggestion could be used for many things, all kinds of stuff. It just has to be implemented in a way that is safe from the problems that can arise from using direct input. Either that, or scripts that use it must be written to protect against these things, as the keypad example I made above demonstrated.

Your idea is great for what it is, creating a mouse-controlled menu of sorts, but IMO not as versatile as this function could be. This one makes this stuff dead simple.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”