|
![MeanGoof wrote this scripting tutorial to help the MiGHTY [TiC]Clan and others.](http://www.ticclan.com/tutorials/meangoofs-script-lessons/images/meangoof.gif)
MeanGoof's Scripting Tutorials:
(17 July, 2002)
(By: "Meangoof")
(Former [TiC]Clan Guest)
Lesson #4:
Cycler script lesson:
Definition for the purpose of this
class:
We will use the term "doo-dad" through out
this lesson. The definition of a "doo-dad" is:
a which-a-ma-call-it that can be a keyboard key, a mouse button, mouse
wheel, joystick button etc.
Before we get started with the cycler script, I will review
some of the CS commands that will be used during this lesson
(sort of a refresher).
Review of important commands:
alias :
The alias command allows you to create new valid CS commands
that can then be used anywhere a valid CS command can be
used. Its general format is:
alias newCommand "validCSCommand1;validCSCommand2;....;validCSCommandn"
This line creates a new command called newCommand, which
when executed; executes validCSCommand1 ... validCSCommandn
in the order specified in the alias line.
bind :
The bind command allows you to associate a doo-dad on your
keyboard, mouse, or joystick to a valid CS command. Its
general forms are:
bind "doo-dad" "validCSCommand"
bind "doo-dad" "+aPlusMinusCommand"
bind "doo-dad" "aCompoundCommandPart1;...;aCompoundCommandPartn"
In the first form, when the doo-dad is pressed, the
validCSCommand is executed.
In the second form, when the doo-dad is pressed, the +aPlusMinusCommand
is executed, and when the doo-dad is released, the -aPlusMinusCommand
is executed.
In the third form, when the doo-dad is pressed, the commands
bound to the doo-dad are executed one at a time from left to
right.
+/- commands :
Commands for which the + version is normally bound to a key.
When the key bound to it is pressed, the + version is
executed, and when the key is released, the - version is
executed.
+speed and -speed :
This is a +/- command. When the +version is executed, the
player starts to walk, and will do so until the -version is
executed.
+duck and -duck :
This is a +/- command. When the +version is executed, the
player goes into a crouched position, and will stay in the
crouched position until the -version is executed.
wait :
Pauses while the previous command finishes execution. Used
mainly to allow commands time to finish execution. Specially
useful, when commands require response from the server,
which takes time. If the command following a command that
requires a response from the server requires the game state
to have been set by the previous command and is executed
before the previous command has finished execution, the
script will fail in unexpected ways. By putting some wait
commands between the two commands, it allows the first
command to finish execution before the follow-on command
starts execution. Unfortunately, the number of required wait
commands varies depending on the lag of the server, so a lot
of fine tuning is normally required. Sometime a script using
the wait command will work on a server and then will fail on
another server that has a different ping.
example of wait command:
alias +crouchJump "+duck;wait;wait;+jump;wait;wait"
alias -crouchjump "-duck;wait;wait;-jump;wait;wait"
developer and echo :
Use a combination of these two commands to echo a message to
the top left hand corner of your HUD.
example:
developer 1;echo This message is displayed on your
HUD;developer 0
The above will display the message on the top left corner of
your HUD.
Basics of cycler script :
A cycler script allows you to use one doo-dad to cycle
another doo-dad through various functions. In essence, it
allows you to use one key for various purposes. For example,
if you are like me, you use the w key on your keyboard to
run forward. With a cycler script, you can make the w key,
make you run forward when you press the first doo-dad. Next
time you press the first doo-dad, the w key will make you
walk forward, the next time you press the first doo-dad, the
w key will make you walk at the crouch, the next time you
press the first doo-dad, the w key will make you walk at the
crouch very slowly, and finally the next time you press the
first doo-dad the w key will be back to the first mode
(making you run forward), and so on, cycling through
indefinitely.
Writing a cycler script :
This particular script as first written by [TiC-BC]Itsbry.
First we create a command that will change its value
(re-aliased) every time the cycler doo-dad is pressed. It is
the command that is bound to the cycler doo-dad, and it will
modify itself on the fly each time it is executed. It will
start off as an alias to another command that we will call
mode2.
alias motionMode "mode2"
So when the cycler doo-dad (which is bound to motionMode) is
pressed, it will execute the mode2 command (which we will
soon define).
Now we will define the various shapes that the motionMode
command will take. Remember, the motionMode command is what
is bound to the cycler doo-dad, so every time the cycler doo-dad
is pressed, this command must (1) set the new functionality
for the motion of the player and (2) re-alias itself
(self-modify) so that the next time the cycler doo-dad is
pressed, a new function will be executed. The following new
commands are the various shapes that the motionMode command
will take:
alias mode1 "-speed;wait;wait;-duck;wait;wait;developer
1;echo In normal running mode;developer 0;alias motionMode
mode2"
alias mode2 "+speed;wait;wait;developer 1;echo In walking
mode;developer 0;alias motionMode mode3"
alias mode3 "-speed;wait;wait;+duck;wait;wait;developer
1;echo In crouch walk mode;developer 0;alias motionMode
mode4"
alias mode4 "+speed;wait;wait;developer 1;echo In slow
crouch walk mode;developer 0;alias motionMode mode1"
The next part of the script is the part that binds specific
keys to the cycler alias. I would recommend that you do this
binding from the console, or that you use the facility
provided by the game controls menu and the kb_act.lst file.
bind "3" "motionMode"
I have used the 3 key on my keyboard as the cycler doo-dad
because it is next to my motion key (w) and is easy for me
to use as a cycle key. You may want to use a different doo-dad.
It is that simple (or that complicated).
That's all there is to cycler scripts.
Back to the top of page
This page was originally created by [TiC]EVIL
28Aug01. Last updated 02/06/03.
|