Ok, first off, I'll tell you the basics. Every line of a script starts with a colon ":" followed by conditions, another colon and actions. A condition is basically what it says right out of the tin, a condition. When this condition is met, all the actions after the second colon will happen. For example:
:state=0:coloff,state=1
Would mean, if the entity's state is set to zero, turn off collision and set the state to one. States are basically user defined conditions, here is a list of basic actions and what they do:
ColOff: Collision off
Suspend: Basically disables the entity
LinkToPlr: Makes the entity always be at the player's position, good for player body etc.
FreeFromPlr: Undoes what LinkToPlr does.
ColOn: Collision on
State=X: Change the state of an entity to X.
Those are some basic actions. Throughout this tutorial you will learn a few more. Every action in a script is separated by a comma "," and the same goes for conditions. Here are some basic conditions:
always: This basically makes all the actions for this line always happen.
never: Opposite of always
state=X: Makes the actions happen if the entity's current state is X.
KeyPressed=X Y: check whether keycode X is pressed (Y=1) or not pressed (Y=0)
ScanCodeKeyPressed=X: Basically the same as KeyPressed, only you can only check if the button is being pressed, this function is not recommended, just use KeyPressed.
PlrUsingAction=X: Check whether the playing is pressing the use key or not (0\1)
MouseState=X: Check whether mouse button X is pressed.
1 = Left Mouse
2 = Right Mouse
3 = Left + Right Mouse
4 = Middle Mouse
5 = Left + Middle Mouse
6 = Right + Middle Mouse
7 = Left + Right + Middle Mouse
8 = Mouse 4
9 = Left + Mouse 4
10 = Right + Mouse 4
11 = Left + Right + Mouse 4
12 = Middle + Mouse 4
13 = Left + Middle + Mouse 4
14 = Right + Middle + Mouse 4
15 = Left + Right + Middle + Mouse 4
So, for example, to check if the entity's state is 5, AND the player is pressing the "T" key (code number 20), and change the state to 6 and then turn off collision if this is true, you would do this:
:state=5,keypressed=20 1:state=6,coloff
To help you out, here is the complete list of scancodes:
To start you off, we'll be making a simple, "middle mouse button to use" script.
Here is a script template, use it to start off all of your scripts:
;Artificial Intelligence Script
;Header
desc = Description of your script
;Triggers
;End of Script
All of your scripting will go inbetween "Triggers" and "End of Script". To edit and make scripts, you can use either "notepad" or "
FPI EditPad", I recommend the latter for newbie scripters. You should also note that any line that has a semicolon ";" ANYWHERE on that line, it will be treated as a comment. Comments are never really needed, but are very handy and make your scripts look cleaner and more attractive.
First off, we'll want to check if the middle mouse button is pressed, so use this for that:
:mousestate=4:
FPI EditPad may give you an error when you use some of the new commands that came with the v1.19 update, this is easy fixed though. Simply download the definitions update by Pyrate Mike
Now we want the player to "use" whatever is in front of them, for this, we'll use the PlrAction command.
PlrAction=X: Forces the player to do one of 11 actions
X = 1 – Fires current weapon,
X = 2 – Zooms current weapon,
X = 3 – Reloads current weapon,
X = 4 – Crouches player,
X = 5 – Jumps players,
X = 6 – Peeks player left,
X = 7 – Peeks player rights,
X = 8 – Forces “Use” key,
X = 9 – Forces left mouse click,
X = 10 - Forces right mouse click,
X = 11 – Jams current weapon of player.
We want to force the "use" key, so we will use the number "8".
So now, your script should look something like this:
;Artificial Intelligence Script
;Header
desc = Middle Mouse Button to Use
;Triggers
:mousestate=4:plraction=8
;End of Script
Save this as MidMouse_ToUse.fpi in your scriptbank, which is usually located in "C:\Program Files\The Game Creators\FPS Creator\Files\scriptbank", or if you own a 64-bit computer, it will be in "C:\Program Files (x86)\The Game Creators\FPS Creator\Files\scriptbank"
Now simply make a new map and assign this script to the "main" section of a trigger zone, and now the mouse3 button should work just like the use key!
Well done!, you've just made your first script.
If you wish to learn more actions and conditions, I suggest checking out Ched80's
Script Syntax List
-TZK