SiN Consoles - Part II
by Eutectic


1. Interactive consoles

An interactive console is by definition a console that the player can use to make something happen in the map. This can basically anything you can think of: unlock or open doors, turn lights on or off, play sounds, etc. But for this, you have to set up a command prompt and/or a menu on the console.

The console command prompt gives the player the possibility to enter specific data such as a password, a command or a numeric value which will determine what action the console will take based on that input.

Menus give the player a set of fixed options or menu items to choose from. When the player uses the console, he can scroll through these options and select the one he wants to activate.

It's possible to set up either one or both on the same console. Of course, in order for any action to take place, SinScript commands are required to process the information from the console. But for now, we will first look at how to set up a command prompt and a menu on a console.


2. The scrolling part of the console

  • Console entity setup


  • Let's resume from where we left off and use the console we made in Part I. Enabling the command prompt on a console is very easy. Select the console in the 2D or 3D view.


    Entity dialog - fraction key

    Hit N to call up the entity dialog. Add the fraction key and set it to 0.5

    fraction: 0.5

    Set the scroll spawnflag. Click on the box next to it to set the checkmark.


  • Script setup


  • Go to the script and remove all the conlayout and conapplayout commands in the thread testcon1_layouttest. You can also comment out a command by typing // plus a space
    at the beginning of the command line (don't remove the wait 5 command though, we'll use it
    later). Then type the following command:

    %con_testcon1 focus console

  • The command prompt


  • Console display - Command prompt

    Save your script and your map. Compile your map and copy both consoles.bsp and consoles.scr to your game's maps folder. Launch SiN and open your map. This is what you should see on your console.

    The console is now ready to accept user input.
    Console display - Typing input



    Use the console and type something at the command line. I typed hello in this example but you can type any valid ASCII character.

    Hit enter. By doing this, you have effectively passed the character string "hello" to the console as data input. Even though there aren't any commands in the script (yet) to process this data, it was passed to the console nevertheless. We will look at console data processing later.

    After you hit enter, the text you have typed disappears and the console display goes back to the command prompt seen above. The console is again ready to accept data input.



  • Printing scrolling text


  • There's another thing that relates to this portion of the console: the conprint command. This command will simply print text directly above the command line. For example, add the following command to your script:

    %con_testcon1 conprint "What do you want?"

    Console display - conprint command

    Save your script and copy it to your game's maps folder. Launch SiN and open your map. This is what should appear on your console after a 5 second delay.

    The syntax for the conprint command is pretty straightforward as you can see. Just make sure you enclose your text string between double quotes. Fancy layout strings and colored text don't apply here, just plain and simple white text.


    You remember what we set the cols (columns) key to for this console? That's right, 20. This means that the console can display up to 20 characters of text per line. In the above example, the text string is 17 characters long (a space counts as a character) so it can fit on a single line. But what if the text string is longer than 20 characters? Let's try one that's very long and see what happens:

    %con_testcon1 conprint "What do you want? Leave me alone or I'll have Bruno come down here and tap dance on your ass!"


    Console display - conprint commandAs you can see here, the text will automatically wrap around the console and start a new line until the whole string is printed.

    But the thing I want to bring to your attention here is the fact that every time a new line is started, the previous line scrolls upwards until the complete text string is printed. And that's why this is called the scrolling part of the console.

    So to resume, the scrolling part of the console includes:

    1. The command line
    2. The output of conprint commands


    You can clear the text output of conprint commands on the console by using the command:

    %con_testcon1 conclear


    In the example above, we simply let the text wrap around by itself but if you want, it's also possible to insert carriage returns in your text string if you want the text output to be displayed in a certain way. This is done with the special \n character. Modify the conprint command so it now reads as follows:

    %con_testcon1 conprint "What\ndo\nyou\nwant?"

    Save your script, copy it to the maps folder and run your map. See the result:


    Console display - Using the \n character



    Since you inserted a \n (carriage return) character after each of the first 3 words, every word in the sentence is printed on its own line and the entire text string occupies 4 lines on the scrolling part of the console.

    Before we move on, change the conprint command's text string back to what it was before. I just like that joke too much and besides we're going to need it for what comes next.




  • What does the fraction key do?


  • The next essential thing to understand about the scrolling part of the console is the fraction key. Earlier, I told you to set it to 0.5. But why? What does this key do? The description in the entity dialog comments says: This is the fraction of the console you want the scrolling part to take up on the screen. Now let's try to clarify this a bit.

    You already know what the scrolling part of the console includes: the command line and the output of conprint commands. Earlier, I also said that it's possible to have both a command prompt and a menu on a console. The fraction key was designed with this in mind. It determines which percentage of the console surface will be allowed to display the scrolling part elements of the console. Here again is a picture to help you visualize this:


    Console display - Console fraction


    This is the area in which you would normally place your menus. No scrolling text will displayed in this part of the console surface.

    Thus, no overlap between the menus and scrolling text will occur if you confine your menus to this area if fraction = 0.5 or less.




    This is the area in which the command line and scrolling text output will be visible.

    Since fraction = 0.5, that's 50% of the total console surface which means 10 lines maximum since the rows key is set to 20.

    The scrolling elements of the console in our example presently occupy only 6 lines: the command line plus 5 lines of text output by the conprint command. So there's room for 4 extra lines of visible text output.

    Let's modify the fraction of the console and see what happens. But instead of modifying the value of the key in the entity dialog, let's do this directly in the script and learn a new command by the same occasion: confraction. This command does exactly the same thing as if you had changed the value of the fraction key in the editor with the difference that you don't have to save and recompile your map for the effect to take place. So just add this command to your script just before the conprint command:

    %con_testcon1 confraction 0.2

    Also, in order for you to have time to see what's happening, let's split the conprint command into 5 separate commands (one for each line) and insert wait commands between each line. This will slow down the text output so you can see the text scroll slowly line by line on the console instead of getting the visual impression that all the lines are printed at once. Just replace your present conprint command by the following commands:

    %con_testcon1 conprint "What do you want?"
    wait 1
    %con_testcon1 conprint "\nLeave me alone or"
    wait 1
    %con_testcon1 conprint "\nI'll have Bruno come"
    wait 1
    %con_testcon1 conprint "down here and tap"
    wait 1
    %con_testcon1 conprint "\ndance on your ass!"


    Save your script, copy it to the maps folder and run your map. Observe the result:


    Console display - Console fraction






    This is the area in which you would normally place your menus. No scrolling text will displayed in this part of the console surface.

    Thus, no overlap between the menus and scrolling text will occur if you confine your menus to this area if fraction = 0.2 or less.



    Since fraction = 0.2, that's 20% of the total console surface which means 4 lines maximum since the rows key is set to 20.

    The scrolling elements of the console in our example presently occupy 6 lines: the command line plus 5 lines of text output by the conprint command. Since there's only room for 4 lines in the visible fraction of the console, the first 2 lines of printed text scroll out of view and are hidden.


  • Acquiring user data input


  • The time has come for us to learn how to make the console really interactive. So far in the examples above, we learned how to print scrolling text on the console. So it's not exactly a passive console anymore but it's not truly interactive yet because the script doesn't have the necessary commands to process user input and take action based upon that input.

    The best thing to do at this point is to use what you have learned above and build upon that to show you how to make your console interactive. But first, I have to introduce an essential notion that you will need in any interactive console: the console variable. This requires that you be familiar with variables and how they are used in SinScript. If necessary, refer to the variables reference document on this site. It will also require an effort of imagination on your part since there's no way to illustrate this concept graphically.

    When you refer to a console in script commands such as:

    %con_testcon1 confraction 0.2

    You are in fact refering to the console object or the console entity if you will. This is the reason why you place a % character in front of the console name: to let the script know you're refering to the console object. When a console entity spawns in the game, a special variable with the same name as the console entity's consolename is automatically created: the console variable. In our present example, the name of the console variable is con_testcon1 without the % character.

    Why is this variable necessary? Because this is the only way a console can pass user input from the console to the script for processing. This is how a console can be interactive.

    BUT... it's important to emphasize here that the console variable is a special variable and cannot be used with the usual variable operators (ifstrequal, ifstrnotequal, etc.) normally associated with regular script variables (game, level, local or parm variables). In a nutshell, there's only 2 things you can do with the console variable. Those 2 functions and their corresponding commands are:

    1. Monitor the console variable and wait until user input has been passed to it:

            waitForConsole con_testcon1

    2. Pass the data it contains to a regular script variable:

            local.regular_variable coninput con_testcon1

    These 2 commands are always used whenever you need to acquire user input from a console and pass it to the script. Please pay special attention to this as it's essential to understand the concept of the console variable to create interactive consoles. You will also be using these commands with interactive menus.


  • Processing user data input


  • Once the user input is passed to a regular script variable, you can then do whatever you want with it. The typical thing to do with it at this point is to compare the variable to a value or a set of values with variable conditional operators (if* commands) and make the script decide what action will be taken depending on the result of the comparison.

    This is getting pretty theoretical so let me just give you an example script you can try here. It's a basic "decision making" script based on user input with a minimal amount of commands and it includes the conprint commands from the previous example. BTW, in case some of you don't know, you can select the text straight from this page, copy it and paste it straight into your script to save yourself a lot of typing. Here it is:

    // Main script

    waitForPlayer
    thread testcon1_thread
    end

    // testcon1 thread

    testcon1_thread:
    %con_testcon1 confraction 0.3
    %con_testcon1 focus console
    wait 1

    // wait until the player types something at the console & hits enter

    standby_for_user_input:
    waitForConsole con_testcon1
    local.userinput coninput con_testcon1

    // check if the player typed hello & decide: go to label if he didn't

    process_user_input:
    local.userinput ifstrnotequal "hello" goto cant_do_nuthin_wit_dis

    // this gets executed if the player types hello & hits enter

    stuffcmd "play dialog/general/phone/phone1.wav"
    %con_testcon1 conprint "What do you want?"
    wait 1
    %con_testcon1 conprint "\nLeave me alone or"
    wait 1
    %con_testcon1 conprint "\nI'll have Bruno come"
    wait 1
    %con_testcon1 conprint "down here and tap"
    wait 1
    %con_testcon1 conprint "\ndance on your ass!"
    wait 1
    %con_testcon1 conclear
    goto standby_for_user_input

    // this gets executed if the player types anything else than hello & hits enter

    cant_do_nuthin_wit_dis:
    stuffcmd "play environment/computer/beeps/affirm3.wav"
    %con_testcon1 conprint "Unknown command"
    wait 1
    %con_testcon1 conclear
    goto standby_for_user_input

    end


    Save your script, copy it to the maps folder and run your map. Once there, walk up to the console, use it, type hello at the console prompt and hit enter. See what happens. Try typing anything else than hello, hit enter and see what happens.

    All the stuffcmd command does BTW is to pass the command between double quotes to the game console the same way as if you had dropped the game console with the tilde (~) key and had typed it in manually. So you can use any valid console command or cvar with stuffcmd.

    Congratulations, you have just created your first interactive console :)


  • An important detail to note


  • That's about it for the scrolling part of the console. Just a quick note to avoid a minor pitfall when processing user input from the command prompt:

    Since user input typed at the console's command prompt can be any possible combination of ASCII characters, the data is passed to the console variable as a text string even if you type a number at the console command prompt. So when in turn, you pass this data from the console variable to a regular variable, this variable will automatically be a string variable. Therefore, when you process that variable in the script with conditional operators, you must use string type operators such as ifstrequal, ifstrnotequal, append*, etc. If you try to use number type variable operators such as ifequal, ifless, etc., the script will report an error in the game. Always treat data acquired from the console's command prompt as text and not numbers.


  • Common practice


  • It is common practice among professional Sin map designers when they write scripts to assign the name of the console variable and the name of the console object to a couple of string variables right from the start in their scripts. You will see this often at the beginning of the thread which is responsible for monitoring and processing the information passed to the console:

    local.Console string "con_testcon1"
    local.ConsoleObject string "%con_testcon1"


    From there on, the console variable and console object are always refered to in the script by these variables instead of by their explicit names.


    3. Console menus

    Probably the most widely used and certainly the most interesting feature about interactive consoles is menus. Menus display a number of menu items that the player can scroll through and select from. Each selection produces a different action in the game.

    Setting up interactive menus on a consoles differs from the command prompt mainly in that they require one or several menu files separate from the main script file to work. They also involve the use of layout strings which were covered in detail in Part I and dedicated menu commands.


  • Console entity setup


  • Let's first go to the editor and add the necessary key and spawnflag to enable menus on your console. Select the console in the 2D or 3D view.


    Entity dialog - menufile key

    Hit N to call up the entity dialog.
    Add the menufile key and set it to menus/testcon1.mnu

    menufile: menus/testcon1.mnu

    Set the menu spawnflag. Click on the box next to it to set the checkmark.


  • Menu file and menus folder setup


  • Since I told you to set the menufile key to make the console point to a menu located in the menus subfolder, we first have to make sure that you have such a folder under the game's sin/base folder. If you don't have one, create it now.

    Next, open that folder, create a normal text file in it and rename it to testcon1.mnu. Open the file in your favorite text editor and you're all set to start writing your menu commands. Of course, I could have told you to set the console's menufile key to point to the maps folder instead and told you to create the menu file in that folder and the console menu would work just the same. But it's a cleaner way to work and it's easier to find your menu files when they're in a dedicated folder separate from the maps folder. It's not essential but it's considered good practice. At least, that's how Ritual and 2015 did it for their menu files.

  • Write a menu file


  • Now you must write the menu commands that will make your menu functional. I will explain what those commands are, how they work and what they do later. But for now, I will ask you to simply copy the text from the sample menu below. It's a basic menu reduced to its most simple expression:

    // Basic console menu for 60 x 60 tutorial console

    menulevel Main

    menuitem "xl 3 yt -6 fc 1 1 1 1 string \"MENUITEM 1\""
    selitem "xl 3 yt -6 fc 1 0 0 1 string \"SELITEM 1\""
    enditem

    menuitem "xl 3 yt -12 fc 1 1 1 1 string \"MENUITEM 2\""
    selitem "xl 3 yt -12 fc 1 0 0 1 string \"SELITEM 2\""
    enditem

    menuitem "xl 3 yt -18 fc 1 1 1 1 string \"MENUITEM 3\""
    selitem "xl 3 yt -18 fc 1 0 0 1 string \"SELITEM 3\""
    enditem

    menuitem "xl 3 yt -24 fc 1 1 1 1 string \"MENUITEM 4\""
    selitem "xl 3 yt -24 fc 1 0 0 1 string \"SELITEM 4\""
    enditem


    Next, comment out this line in your script:

    // %con_testcon1 focus console

    Save your menu file. Save your map and your script, compile your map and copy it along with your script to your game's maps folder and run your map. This is what you should see on your console:


    Console display - Basic menu

    Walk up to the console and use it. You will notice that the top menu item says SELITEM 1 and is colored in red. This is because the first menu item in a console menu is always selected by default.

    Now use the up arrow and down arrow keys to scroll up and down through the menu items. You will notice that the text of the selected menu item always reads SELITEM x in red while the text of the unselected menu items always read MENUITEM x in white.

    For the time being, this is all your console can do.




  • The basic menu commands


  • Let's take a look at the individual menu commands so I can explain what each one does:

    menulevel Main

    The menulevel command basically designates the name of your menu. Right now, it doesn't serve any purpose but it will later when we take a look at hierarchical menus.


    menuitem "xl 3 yt -6 fc 1 1 1 1 string \"MENUITEM 1\""

    The menuitem command does exactly what it says, it creates a selectable menu item on the console and uses the layout string information that follows immediately after it to tell the console what to display, where and in what color, etc. In the present case, it's the text string MENUITEM 1, in white, positionned 3 console grid units to the right of the left edge of the console and 6 console grid units below the top edge of the console. The menuitem layout string is the one that gets displayed whenever the item is not selected.


    selitem "xl 3 yt -6 fc 1 0 0 1 string \"SELITEM 1\""

    The selitem command stands for selected item. It is used along with a menuitem command and is normally written right after it. It uses the layout string information that follows immediately after it to tell the console what to display when the menu item on the console is selected by scrolling to it with the arrow keys.


    enditem

    The enditem command signifies the end of the menu commands associated to an individual selectable menu item on the console. It is mandatory and must be used as the last command of every menu item section.



  • Making the menu items do something


  • At this point, even if you hit enter after selecting a menu item, nothing happens. This is because there is no action is assigned to any of the menu items. Assigning an action to a menu item is done by using the actionitem command inside a menu item section. Here's the basic syntax:

    actionitem "<action command>"

    Let's break this syntax down further and look at what you can use as action command with actionitem. If we refer to Scott Alden's Console Black Magic reference document, we can see that there are 6 possible types of action commands:

    stuffcmd \"<console commands>\"
    centerprint \"<text string>\"
    consolecmd <string>
    pushmenu <menulevel name>
    callback <function string>
    function <function string>


    The callback and function actions are beyond the scope of this tutorial and besides, I don't have a clue what they do.

    The pushmenu action is used for hierarchical menus. This is one of the advanced features of console menus we'll be looking at in Part III of this tutorial.

    The consolecmd action is used to make the menu selection pass data to the console variable. We'll take a look at this a little later.

    You already know what the stuffcmd script command does (re: example script in the previous section on the console command prompt), well the stuffcmd action does exactly the same thing. The centerprint action simply prints a text string enclosed in a box right in the center of your screen.

  • The stuffcmd and centerprint action commands


  • For now, to keep things as simple as possible, I'll give you an example on how to use the stuffcmd and centerprint actions since they are straightforward and don't require any interaction with the script. Please note that the console command and text string used with those actions commands should always be enclosed in \" delimiters.


    Edit your menu file so it now looks like this:

    // Basic console menu for 60 x 60 tutorial console

    menulevel Main

    menuitem "xl 3 yt -12 fc 1 1 1 1 string \"START ALARM\""
    selitem "xl 3 yt -12 fc 1 0 0 1 string \"START ALARM\""
    actionitem "stuffcmd \"play environment/alarm/bank.wav\""
    enditem

    menuitem "xl 3 yt -18 fc 1 1 1 1 string \"STOP ALARM\""
    selitem "xl 3 yt -18 fc 1 0 0 1 string \"STOP ALARM\""
    actionitem "stuffcmd \"stopsound\""
    enditem

    menuitem "xl 3 yt -24 fc 1 1 1 1 string \"LAUNCHER + 40 AMMO\""
    selitem "xl 3 yt -24 fc 1 0 0 1 string \"LAUNCHER + 40 AMMO\""
    actionitem "stuffcmd \"give rocketlauncher; give rockets 40\""
    enditem

    menuitem "xl 3 yt -6 fc 1 1 1 1 string \"PRINT MESSAGE\""
    selitem "xl 3 yt -6 fc 1 0 0 1 string \"PRINT MESSAGE\""
    actionitem "centerprint \"This is what\ncenterprint does\""
    enditem


    Save your menu file and run your map. This is what your console display should look like now:


    Console display - Interactive menuWalk up to the console and use it. The first menu item is selected by default so if you hit enter right away, the actionitem assigned with this menu item will be executed. This will play an alarm bell sound that loops indefinitely.

    If you want to stop the sound, scroll down to the second menu item with the down arrow key, it will turn red. Hit enter.

    The third menu item will give you a rocket launcher plus 40 rockets when you hit enter. Notice in the menu file that the stuffcmd command string can include several game console commands each separated by a semi-colon.

    The fourth menu item will print text in the middle of your screen in a box. Please note that you can use the \n character to insert a carriage return in your text string.

    So there you are. That's your first interactive console menu :)


    So to resume all this:

    1. The menuitem command determines the visual attributes of the menu item when it's unselected.

    2. The selitem command determines the visual attributes of the menu item when it's selected.

    3. The actionitem command determines what action is taken when the menu item is selected and the     user hits enter.


  • The consolecmd action command


  • This command is the one to use if you want your console menu to interact with the script. Its role is to pass data to the console variable. Here's the basic syntax:

    actionitem "consolecmd <string>"

    When the menu item is selected and the user hits enter, the value of string is passed to the console variable. You can use any combination of letters and numbers you want for string (no spaces are allowed though) but it's best to assign it a number. Why? Because this way, the data passed to the console variable can be treated as a number variable instead of a string variable and that gives you a wider choice of variable operators in your script when you need to process the user input in more sophisticated ways than a simple comparison with a fixed value.

    Don't worry if you don't understand this. Just use numbers.

    So let's just start with an example menu and script which shows how to use this. The script will also use the scrolling part of the console to display messages. Here's the menu:

    // Basic console menu for 60 x 60 tutorial console

    menulevel Main

    menuitem "xl 3 yt -12 fc 1 1 1 1 string \"QUICK CASH!\""
    selitem "xl 3 yt -12 fc 1 0 0 1 cursor string \"QUICK CASH!\""
    actionitem "consolecmd 1"
    enditem

    menuitem "xl 3 yt -18 fc 1 1 1 1 string \"FREE FOOD!\""
    selitem "xl 3 yt -18 fc 1 0 0 1 cursor string \"FREE FOOD!\""
    actionitem "consolecmd 2"
    enditem

    menuitem "xl 3 yt -24 fc 1 1 1 1 string \"EASY CHICKS!\""
    selitem "xl 3 yt -24 fc 1 0 0 1 cursor string \"EASY CHICKS!\""
    actionitem "consolecmd 3"
    enditem

    menuitem "xl 3 yt -6 fc 1 1 1 1 string \"JC IS AN EEDIOT!\""
    selitem "xl 3 yt -6 fc 1 0 0 1 cursor string \"JC IS AN EEDIOT!\""
    actionitem "consolecmd 4"
    enditem



    And here's the script:

    // Main script

    waitForPlayer
    thread testcon1_thread
    end

    // testcon1 thread

    testcon1_thread:
    local.Console string "con_testcon1"
    local.ConsoleObject string "%con_testcon1"
    local.ConsoleObject confraction 0.1
    local.ConsoleObject focus menu
    wait 1

    // wait until the player selects a menu item & hits enter

    standby_for_user_input:
    waitForConsole local.Console
    local.userinput coninput local.Console

    // determine what menu item what selected by the player

    process_user_input:
    local.userinput ifequal 2 goto menu_action2
    local.userinput ifequal 3 goto menu_action3
    local.userinput ifequal 4 goto menu_action4

    // this gets executed if the player selected menu item 1

    menu_action1:
    *1 give coin 4
    *1 playsound "dialog/general/blade/score.wav"
    local.ConsoleObject conprint "PAY DIRT!"
    wait 2
    local.ConsoleObject conclear
    goto standby_for_user_input

    // this gets executed if the player selected menu item 2

    menu_action2:
    *1 give candybar 4
    stuffcmd "play dialog/chem/jc/hungry.wav"
    local.ConsoleObject conprint "COOKIES!"
    wait 2
    local.ConsoleObject conclear
    goto standby_for_user_input

    // this gets executed if the player selected menu item 3

    menu_action3:
    spawn chemfem.def targetname fem1
    stuffcmd "play misc/civfem/scream.wav"
    wait 0.3
    *1 playsound "dialog/general/blade/comepapa.wav"
    local.ConsoleObject conprint "CAKES!"
    wait 2
    local.ConsoleObject conclear
    goto standby_for_user_input

    // this gets executed if the player selected menu item 4

    menu_action4:
    *1 take coin 4
    *1 take candybar 4
    $fem1 gib
    stuffcmd "play dialog/bank/jc/nffn2.wav"
    local.ConsoleObject conprint "YOU'RE BUSTED PAL!"
    wait 2
    local.ConsoleObject conclear
    *1 playsound "dialog/subway/cin/bkickass.wav"
    waitForSound "dialog/subway/cin/bkickass.wav"
    goto standby_for_user_input

    end


    Save your menu file and your script. Copy the script to the game's maps folder and run your map. This is what your console display should look like now:


    Console display - Interactive menuWalk up to the console and use it. I modified the selitem layout strings in the menu and used cursor string to get that arrow style cursor in front of the selected menu item text. This is just for looks. Every menu selection plays a sound and prints text on the scrolling part of the console.

    The first item will give you 4 quarters.

    The second item will give you 4 candy bars.

    The third and fourth menu items are surprises unless of course, you can make out what will happen by reading the code in the script for those menu item actions :)




  • An important detail


  • Just a little thing before we wrap this up. It is important to note that you can have both a scrolling part (command prompt) and menus enabled on your console entity in SinEd. This is done by checking both the scroll and menus spawnflags.

    But I should point out that the player cannot access both the command prompt and the menu at the same time, it's either one or the other. You can control whether the player has access to the command prompt or the menu on the console by using the focus script command.

    To give the player access to the console's command prompt, use the command:

    %con_consolename focus console

    When the focus is set to console, the command prompt will appear and you will be able to type in commands. Your menu will still be displayed but it won't be accessible.

    To give the player access to the console's menu, use the command:

    %con_consolename focus menu

    When the focus is given to menu, the command prompt will be hidden and you will be able to access your menu selections.

    If you don't use the focus command in your script and you have enabled both a scrolling part and a menu on your console, the focus will automatically be on the menu by default.


    4. The finishing touch

    Did you ever notice that in the original maps of Sin, whenever you use a console, your regular first person view changes to a fixed view and the console display instantly occupies the most part if not the entire width and height of your screen? Did you notice that in this view, the player can't move and "looks straight ahead" at the console display no matter in what position he was when he used it?

    Ever wonder how this is done? Well, it's actually very simple: by using the func_camera entity.

    The basic principle is to place a func_camera entity in front of your console display and make the console entity target the func_camera entity. The rest is mainly tweaking the placement of the func_camera until the view is exactly the way you want it. Let's make one for the console we used in our examples.


    XY view - draw func_camera brush

    Hit 3 to set the grid to 4 x 4 and draw a brush 16 units wide by 16 units high by 8 units thick so that the center of this brush is 44 units away from the console's entity's display face.

    The texture and brush size really don't matter. Only the position of the center of the brush does so it's a good idea to keep it small and symmetrical. Make sure that the brush's center is aligned vertically and horizontally with the console brush's center.
    Entity menu - func_camera



    Do a RightClick on the brush and select func_camera from the pop-up menu.
    Entity dialog - func_camera



    Hit N to bring up the entity dialog for the func_camera and set the angles key to make the camera look in the proper direction. In this example, this happens to be 0 0 0.

    Then set the targetname key to t1 so that the console entity targets the func_camera entity.

    Don't forget to set the console's target key to t1.


    XY view - func_camera ready3D view - func_camera ready

    Your func_camera is now in the proper position and all set for the "console view" effect in the game.

    The func_camera brush is invisible in the game BTW.


    Save your map, compile, copy it to the game's maps folder and run it. Walk up to the console, use it and see the result.

    5. Conclusion

    Well that's it for the basics of interactive consoles. Again, sorry if it was long but there's many many things to cover about consoles. With these examples and info, you should have what you need to start making fully functional interactive consoles. The rest is mainly experimentation. Consoles are extremely powerful and there's virtually no limit to what you can make them do. Don't forget to go back often to Aldie's reference document Console Black Magic for particular details about all the other possible options and command syntax. What I have described is only a tiny fraction of all the stuff that you can do with consoles and the topic is so vast one could easily write a book about them.

    In the next and last part of this tutorial, I will cover some of the more advanced features of consoles: hierarchical menus, header items, image menu items, slider items, list items and field items. It will consist mainly of working examples through which I will move more quickly and leave most of the interpretation to you. If you are comfortable with basic lessons above, then Part III has some interesting features and neat tricks for you. Be aware though, that it's more advanced in nature so it's strongly recommended you understand the basics thoroughly before you go on.


    Part I

    Part III