Quote: Originally Posted by Emerald
What does bind a key ingame to "xtog" mean?
Ok. Quick breakdown of the XTOG script and a mini-script lesson while we're at it. I will assume a basic knowledge of computers and concepts (such as VARIABLES).
Code:
alias xtog "xtog1"
alias xtog0 "gl_spriteblend 1; cl_xhair_style 0; alias xtog xtog1"
.
.
.
alias xtog20 "gl_spriteblend 0; cl_xhair_style 16; alias xtog xtog0"
ALIAS. The alias command accepts 2 parameters (also called arguments) of the format:
Code:
alias NAME "COMMANDS"
It assigns the "COMMANDS" portion to the function NAME. This simply means that we can access "COMMANDS" by using NAME. The reason we use quotes is to be more specific. It will accept unquoted arguments, however, to BE SURE that you don't include unwanted information, we use the quotation marks as DELIMITERS.
Quote:
de·lim·it·er (dĭ-lĭm'ĭ-tər) Pronunciation Key
n. Computer Science
A character or sequence of characters marking the beginning or end of a unit of data.
EXAMPLE:
Code:
alias CHANGEMYNAME "name MeinGottHasSexyManBoobs"
So whenever I were to use CHANGEMYNAME..it would actually execute the information inside the quotations, which is simply to change your name.
A nice feature of the ALIAS command..is that you can assign it to other ALIAS'ed code blocks!
EXAMPLE:
Code:
alias CHANGEMYNAME "ABC"
alias ABC "name DiamondLooksLikeJesus"
So the first line says -Hey..whenever they use CHANGEMYNAME..they want to execute ABC.- You can see in the 2nd line that ABC holds the command to change a name. So it'd be like:
CHANGEMYNAME ---> execute "ABC" ---> ABC ---> execute "name DiamondLooksLikeJesus"
So the first line of our script file so far:
***NOTE: Generally, when programming, you want to name variables in a way that makes it easy to figure out what they are. XTOG stands for "X"hair "TOG"gle.***
This line is important. We will use THIS FUNCTION NAME (XTOG) to assign a key to. This key will cycle us through each crosshair. So we want XTOG to execute "xtog1" whenever we call it. Easy enough. On to line 2 (and the subsequent lines):
Code:
alias xtog0 "gl_spriteblend 1; cl_xhair_style 0; alias xtog xtog1"
You see those semi-colons? They act as delimiters for seperate commands. This way we can include multiple commands inside of one code block. So we know that xtog0 is going to execute some commands. What are they? Let's go one by one.
This piece of code is assigning a value to a variable. More specifically, these variables are called CVARS ("Configuration Variables"). They allow us to set information that the target program uses. In this case, we're setting information for the half-life engine to use. Some CVARS in half-life/HL mods are preceded by IDENTIFIERS. If you see something with "gl_" then you know that variable directly deals with the client side graphics. "sv_" is a server set variable. "cl_" is a client side generic variable. "r_" deals with client side rendering. Here is a comprehensive list of CVARS (though by no means a complete list).
http://commands.planethalflife.games...ds/index.shtml
So we find that gl_spriteblend turns on/off (by specifying a 1 or 0)..well..sprite blending.
Ah. We know immediately that this is a CVAR..and the preceding identifier is "cl_". This means it's a client side variable. It happens to set the number of the crosshair in your .spr file that you would like to use. A value of "0" here sets your crosshair to the default dod crosshair you had selected.
What's going on here? We're re-assigning XTOG? That's right. This is the way you make a toggle script. This will allow us to assign XTOG to one key..then be able to press that one key repeatedly to cycle through commands. We just redirect the original alias to the next bit of code we want to happen whenever the key is pressed. So as it stands..when this piece of code executes..the next time we press the key we bound to XTOG..it will execute XTOG1.
Code:
alias xtog20 "gl_spriteblend 0; cl_xhair_style 16; alias xtog xtog0"
I included this one so you can see the last piece of code that resets the whole cyclic toggle. Specifically:
This piece of code will reset your bound XTOG key...and make it execute xtog0 the next time the key is pressed. Thus, the whole thing loops infinitely.
This brings us, finally, to "what does binding 'xtog' to a key mean?" In order to execute all those nifty functions we have...we have to be able to tell the game to do so. We can't just yell at our monitor. Half-life allows you to BIND your keys to different functions. This means that whenever we press that key..it will execute the function(s) we told it to. "xtog" is the function we need to call to make our script cycle through. There are multiple ways of binding keys. For our example, you'll want to put this piece of code somewhere in your USERCONFIG.CFG.
General BIND command format:
Code:
bind "KEY" "COMMANDS"
Generic XTOG BIND.
Replace KEY with the KEY you want to use. For example:
This will make it so that when I press K..it will execute "xtog".
*The USERCONFIG.CFG will only execute when a particular game is run. This way we can change bindings depending on our mod. So I can have different CS binds from DOD.*
I hope this helped in some way. If I've confused the tar piss out of you..I apologize. This was a very, very quick explanation with little depth and the assumption you understand certain computer concepts. If you have questions..feel free to PM me. I'll be more specific with more exacting questions.
GO GO GO GO GO GO GO GO GO OWNED.