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 / Crusader2's Basic Scripting Tutorial

Author
Message
Crusader2
16
Years of Service
User Offline
Joined: 8th Aug 2008
Location: Somewhere...
Posted: 19th Mar 2009 19:42 Edited at: 22nd Mar 2009 02:20
Crusader2's Scripting Tutorial

(Note: Bold words are important and will be refrenced to at another point)

All right, let's get started learning the basics of the FPI language, which is what FPS Creator uses.

Part 1: What is scripting?
Scripting is the writing of code in a format that is readable to the computer and makes anything function. This goes from the very operating system you use on your computer to the antivirus software, if any, that you use. Scripting is how game makers make things happen. Not just a player walking around, but how certian people come running at certian times, and how enemies attack the player.

Part 2: Why should I learn to script?
Well, if you ever want a game you make to go beyond just a player running around, shooting random enemies, then you should learn. Scripting will allow you to tell the player what to do, whether it is in the form of a voice or in the form of a HUD. Scripting allows game desigers to expand on their ideas and actually set them into motion.

Part 3: The Basics
There are 2 basic principles behind any coding language. Those 2 things are the Syntax, and the Commands.
a) Syntax: The syntax is the format the code is layed out in. Languages have varying syntaxes, but the FPI Language has a very simple syntax. I'll get to that later.
b) Commands: The commands are what actually makes the code work. They tell the system when to do what, and how to do it. You'll learn more about commands later.

Part 4: The FPI Language
Ok, now that you know the basics of scripting in general, it's time to actually start learning the FPI Language. We'll do that by disecting some of the code already given to us the The Game Creators. The following code is the code from the file light1.fpi.



That looks a little complicated, huh? Well, not to worry, this is actually easier than it looks.
Let's start at the top.



See how this line starts with a semi-colon ( ; )? That means it is a COMMENT, and is not essential to how the code functions. Comments are put in place to tell users more about the code they are looking at.

The next line says:



This is another description of the script, much like a comment. HOWEVER, a DESCRIPTION LINE is essential to how the code works. It doesn't do anything, but it is nescessary to have. You can just put desc= Script if you want to, but it is still essential to have.

Next up is another comment; we're not going to bother with that.

After that is:



Now, this is the actual code. Let's start breaking this apart. The first thing we see is a colon ( : ). This is always the first thing in a line of actual code; we're going to call this the CONDITION COLON, because everything that follows a condition colon is a condition. The next thing in the line of code is the condition, "state=0". "State" is an internal variable that determines when something is activated. When is says, "state=0", that means that the code will execute all following commands ONLY WHEN state is equal to 0.
(NOTE: By default, the variable state is always set to 0 at the beginning of a script.)
After ":state=0", we see another colon. This is not another condition colon, because "state" cannot be set to 2 values at once. This is an ACTION COLON. Everything following an action colon is an action. The action following the action colon, "state=1", means set the state to 1.
So, this first line of code means, "If the state of this script is equal to 0, set the state of this script to 1."

The next line of code is:



Again, we see a condition colon and an action colon. Both of these elements make up the syntax of the FPI language. The syntax for the the FPI language is:



Now, let's get to disecting our second line of code. First off, we see ":state=1". We already know what this means, so let's move on to ",activated=0".
The first thing here is a comma. This comma joins 2 pieces of code; it is different for conditions and actions. Either way, we're going to call this comma a CONJUNCTION COMMA. When it is in a condition, it means that all conditions stated must be met before any actions will take place.
Next is the condition, "activated=0". "Activated" is another internal variable which is much like state. However, activated can be changed from a different script.
(NOTE: By default, activated is set to 0 at the beginning of a script)
Next we see an action colon, followed by "state=2". We already know what that does, so let's move on.
Finally, we see the command "lighton". This command does just what it sounds like it does; it makes the light the script is assigned to turn on.

The last line of this script is:



First, we see a condition colon, followed by "state=2", followed by "activated=1". Now, wait a second. In this script, it doesn't say that the variable "activated" is changed at all. That means that the variable for activated must be changed through another script!
Next, we see an action colon followed by "state=1", then followed by "lightoff", which turns the light off.

Now, for an explination. Since the variable "activated" can only have one value at a time and can be changed from another script, it would make sense to create another script that would change "activated" for this script and apply it to a switch, since swithces are traditionally used to turn lights on and off. If the light is turned off, through the use of another script, it immediately checks to see if the variably changes back and will turn the light on if it is.

Well, since you now know the basics of scripting, go out and experiment!

Best wishes and best of luck!
Crusader2

CLOSING NOTES:
I would reccommend downloading FPIEditpad, which contains all of the conditions and actions available.
I would also reccommend Ply's Mod, which expands vastly on the scripting language of FPI.
FPIEditpad also has a download that contains all of the commands and conditions available through the use of V1.09 in conjunction with Ply's Mod.

Some people say that I'm crazy... And I agree.
USE PLY'S MOD!
The Fps Creator rocks!
16
Years of Service
User Offline
Joined: 24th Oct 2008
Location: Sneaking down your chimney.
Posted: 20th Mar 2009 21:59
Good tut. But I won't be using this tut because I ALWAYS FORGET the commands and other stuff. I like the guide one more. But as the title says, it is only a basic tutorial. And it is nice.

I can't texture. I'm not an artist.
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 21st Mar 2009 23:44
Not bad, Crusader. It's well written and easy to follow, but you should a little careful about the smiley's that show up. When putting a colon in parentheses, space it out like so ( : ). That will prevent the smiley from showing up.


The one and only,


Crusader2
16
Years of Service
User Offline
Joined: 8th Aug 2008
Location: Somewhere...
Posted: 22nd Mar 2009 02:20
Thanks Ply, I hadn't noticed that.

Some people say that I'm crazy... And I agree.
USE PLY'S MOD!
The challenge master
15
Years of Service
User Offline
Joined: 4th Apr 2009
Location: 645378463586th dimension
Posted: 5th Apr 2009 00:13
can you please give a list of more commands and descriptions of what they do. that would be very helpful

dodulee du du!

Login to post a reply

Server time is: 2024-11-24 21:28:28
Your offset time is: 2024-11-24 21:28:28