Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / The FPSCreator Scripting Guide Part 1: Introduction and Your First Script

Author
Message
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 10th Jun 2012 08:17 Edited at: 10th Jun 2012 14:41
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:



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:



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

Leongamerz
14
Years of Service
User Offline
Joined: 14th Aug 2010
Location:
Posted: 10th Jun 2012 08:57
Thanks for tutorial mate,it's help me so much.

Irradic,Poloflece,Anayar,PWP,Henry Ham,Cosmic Prophet,Wolf,KeithC,Nickydude,SceneCommander,Dark Goblin And Lee Bamber is my icon.

The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 10th Jun 2012 09:05
@Leongamerz
No problem, glad to be of help.

-TZK

DarthBasicVader
18
Years of Service
User Offline
Joined: 28th Nov 2005
Location: Cyberspace
Posted: 10th Jun 2012 09:32
Good work! Keep it up

Riccardo

Riccardo
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 10th Jun 2012 09:58
@DarthBasicVader
Thanks, I'm out of ideas as to what Part 2 will be though.

-TZK

Ross tra damus
3D Media Maker
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Looking to Escape London
Posted: 10th Jun 2012 13:07
The Zombie Killer

Thanks for taking the time to put this together.Not only does it help me but I'm sure will be helpful to many new/old users also.

Because of the ammount of ways to use the FPI language I guess its hard to say what can come next?

Thanks Again.
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 10th Jun 2012 13:53
@Ross tra damus
No problem, I'm glad to help out this forum, it's the best one I've joined yet. And yeah, I can't really think of anything for part 2 lol.

-TZK

elbow
13
Years of Service
User Offline
Joined: 3rd Dec 2010
Location:
Posted: 10th Jun 2012 14:36 Edited at: 10th Jun 2012 14:37
Hi TZK

Well done on the tut - I would like to disagree and recommend FPI Editpad for beginners, the latter of the two suggestions. It has all the conditions and actions listed in the program. It also helps by picking up faulty lines of script and let's you choose between writing fpi or fpe scripts. It also allows you to link directly to your scriptbank for easy access to previous saved scripts. There are more advantages, but I can't remember them all now.

Regards

Eugene
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 10th Jun 2012 14:41
@elbow
oops! Thanks for noticing that, I actually meant the latter, I got mixed up with my words, my bad! I'll fix it now.
Thanks for the compliment.

-TZK

The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 1st Jul 2012 04:00
Bumpity bump...

-TZK

Login to post a reply

Server time is: 2024-11-24 01:04:51
Your offset time is: 2024-11-24 01:04:51