The states can be named anything and are ran in order, starting from "0" when you use the weapon.
datablock ShapeBaseImageData(swordImage)
{
...
stateName[0] = "Activate";
stateTimeoutValue[0] = 0.5; //This state ends after half a second
stateTransitionOnTimeout[0] = "Ready"; //This changes to the "Ready" state
stateSound[0] = swordDrawSound; //Play the "draw" sound
stateName[1] = "Ready";
stateTransitionOnTriggerDown[1] = "PreFire"; //If the Fire key is pressed, go to "PreFire"
stateAllowImageChange[1] = true; //You can change tools while in this state
stateName[2] = "PreFire";
stateScript[2] = "onPreFire"; //Call swordImage::onPreFire() (see below)
stateAllowImageChange[2] = false; //You can't change tools while in this state
stateTimeoutValue[2] = 0.1; //There is a delay of 0.1 seconds
stateTransitionOnTimeout[2] = "Fire"; //Switch to the "Fire" state after the time out
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "CheckFire";
stateTimeoutValue[3] = 0.2;
stateFire[3] = true; //Used in some scripts reading weapon images to tell if it's firing in that state
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire"; //Play the model's "Fire" animation (makes it swing in first person)
stateScript[3] = "onFire"; //onFire is a default function defined to make the weapon fire its projectile type
stateWaitForTimeout[3] = true; //Can't change to other states until the timeout is done
stateName[4] = "CheckFire";
stateTransitionOnTriggerUp[4] = "StopFire"; //If you have released the Fire key, go to "StopFire"
stateTransitionOnTriggerDown[4] = "Fire"; //If you are still holding the Fire key, go to "Fire" again
stateName[5] = "StopFire";
stateTransitionOnTimeout[5] = "Ready";
stateTimeoutValue[5] = 0.2;
stateAllowImageChange[5] = false;
stateWaitForTimeout[5] = true;
stateSequence[5] = "StopFire"; //Play the model's "StopFire" animation
stateScript[5] = "onStopFire"; //Call swordImage::onStopFire() (See below)
};
function swordImage::onPreFire(%this, %obj, %slot)
{
%obj.playthread(2, armattack); //Play a looping "Swing" animation blended with others (e.g. walking, sitting)
}
function swordImage::onStopFire(%this, %obj, %slot)
{
%obj.playthread(2, root); //Stop the animation in that slot
}