Frictional Games Forum (read-only)

Full Version: Terminal Numpad Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So I have been wrestling with creating a numpad today and I've come nowhere. I tried reverse engingeering FG's script from Upsilon 01_02 in a way to just a get the numpad to show, but I've got zilch clue. My code is therefore a mess and meaningless, no error messages, but also no results.

Does anyone (nudge-nudge) know how to set up a basic numpad that will trigger a doorpanel to unlock? I'm using the small monitor panel if that's vital.
There are two key (ha) parts of it.

First, when you want to display the numpad, you use the function StationGui_Numpad. Generally, all you need to use are the first two parameters, as the default value for the rest will make the numpad display how it is generally intended to for the StationGui look-and-feel. The first parameter is the text that will display at the top of the numpad, and the second parameter is the number of characters in the full code.

Code:
StationGui_Numpad("Numpad Header", 4);

Second, you get the current value of the numpad by using the StationGui_GetNumpadInput function. You can then compare this value against whatever pre-defined code to determine if the player put in the right code.

Code:
tString sCode = StationGui_GetNumpadInput();
if (sCode == "4546")
{
    // Unlock door, change current app, or whatever
}

The simplest way to tie it all together would be to put it all inside nested if-then blocks within your OnGui function:

Code:
if (StationGui_Numpad("Numpad Header", 4))
{
    tString sCode = StationGui_GetNumpadInput();
    if (sCode == "4546")
    {
        // Unlock door or whatever

        // Success beep so the player knows it's the right code
        Depth_Audio_Terminal_Confirm(ImGui_GetName());
    }
    else
    {
        // Error beep so the player knows it's the wrong code
        Depth_Audio_Terminal_Negative(ImGui_GetName());
    }
}
Aight, I'll check it out. Also, is there a list of all the StationGui_X somewhere?
Not yet that I know of. There's a list of the generic ImGui functions on the wiki, but for StationGui specifically you are stuck looking at the script files or at existing map code for the time being.
Alright, the actual numpad shows up now, but how do I set the code for it? I presume it's the four digit number after sCode(?) but that's not it because it gives me the else function when I enter it.

Code:
void DoorNumPad_OnGui(const tString&in asEntityName, float afTimeStep)
        {
        StationGui_Numpad("Numpad Header", 4);
        
        StationGuiBG_Backdrop();
        StationGuiBG_Scanlines();
        
        tString sCode = StationGui_GetNumpadInput();
        
        if (sCode == "1111")
            {
                Button_SetLocked("panel_laboratory_11", true,true);
            
                Depth_Audio_Terminal_Confirm(ImGui_GetName());
            }
        else
            {
                Depth_Audio_Terminal_Negative(ImGui_GetName());
            }
        }
}

On a side note: there's a glitched sound surrounding the panel whenever you're not looking at it. Like it is continuously playing one of the sounds over and over again.
You didn't put StationGui_Numpad as the expression of an if statement. StationGui_Numpad returns true on the frame when the OK button is pressed. The way you have it setup now, it is always checking sCode against your "1111" on every update (30 or so times per second) and that causes one of the two sounds to play every time, which is where the glitched sound is coming from.

Also, your Button_SetLocked function seems to be locking the button rather than unlocking it. I'm not sure if that was your intention, but it might be what is causing you to believe the code isn't working. To unlock the button, use Button_SetLocked("panel_laboratory_11", false, true);
Ah, I see. It's fixed now and working as intended. Expect to hear from me again soon as I attempt terminal-scripting again Big Grin