[ACS] GetValue Function

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ACS] GetValue Function

Re: [ACS] GetValue Function

by skadoomer » Fri Jul 18, 2008 9:03 am

I'm pretty sure this is a limitation of acs, which won't be addressed until a new system, like doomscript or higher equivalent is added. You may be able to fake your way through this by double binding the number keys to scripts as well as weapon slots, but given your limited scripting ability i'd say you may be out of luck.

Re: [ACS] GetValue Function

by Slasher » Sat Jul 12, 2008 2:36 pm

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.

Re: [ACS] GetValue Function

by Isle » Sat Jul 12, 2008 2:27 pm

does the kyboard numberpad count?

Re: [ACS] GetValue Function

by Slasher » Sat Jul 12, 2008 2:26 pm

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.

Re: [ACS] GetValue Function

by Isle » Sat Jul 12, 2008 2:12 pm

Re: [ACS] GetValue Function

by Xaser » Sat Jul 12, 2008 2:11 pm

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

Re: [ACS] GetValue Function

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.

Re: [ACS] GetValue Function

by MartinHowe » Sat Jul 12, 2008 12:46 pm

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

Re: [ACS] GetValue Function

by HotWax » Sat Jul 12, 2008 9:41 am

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...

Re: [ACS] GetValue Function

by Gez » Fri Jul 11, 2008 2:30 pm

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.

Re: [ACS] GetValue Function

by Enjay » Fri Jul 11, 2008 1:43 pm

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?

Re: [ACS] GetValue Function

by Slasher » Fri Jul 11, 2008 11:49 am

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.

Re: [ACS] GetValue Function

by Gez » Fri Jul 11, 2008 11:03 am

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.

Re: [ACS] GetValue Function

by Slasher » Fri Jul 11, 2008 10:39 am

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.

Re: [ACS] GetValue Function

by HotWax » Fri Jul 11, 2008 10:35 am

Something tells me the devs aren't going to be too keen to add an input prompt directly into the game...

Top