Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Common Script Errors: Look here first!
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#1
Common Script Errors: Look here first!

I see a lot of common errors and people asking the same questions here. So I thought I'd make this little "tutorial". If you're having a lot of problems with scripting and don't quite understand it, this will probably help a lot.

#1. ALWAYS put your declarations inside a function. By declaration, I mean the script functions that do something, such as SetEntityActive, or AddEntityCollideCallback. An example of a function would be:

void MyScript(string &in asTimer)

This is a function (as opposed to what you would call a "script function"). EVERYTHING has to go in here. The insides of a function are bounded by these: { and }. Think of it like using regular brackets:

(You wouldn't open a bracket like this and then not close it.

Same with functions, always make sure they are inside the {}. And make sure that there is an equal amount of { to }, and that the {} are inside a function, not by themselves.


#2. Make sure things that need quotation marks, have quotation marks. Things that need quotation marks are things like names of entites (grunts, for example) or sounds and music. True and false do not need them! Neither do any numbered values. So for example:

PlaySoundAtEntity("GruntSound", "enabled.snt", "servant_grunt_1", 2, false)

The first three are names of something, so they need quotation marks. The rest do not. Also, make sure a comma separates all of these, just as if I was typing of list of things. Example:

Today I need to buy milk, eggs, and cereal.

I would separate this list of items with commas. The same applies to the parameters of a script function.

#3. DON'T simple copy someone elses script and think it will work. It will not. You would have to make sure the script has the same names of enemies and objects as your map does, as well as areas. And the script might do something different than what you want it to do.

These are the most common errors I've noticed.


Also, any error that you get will almost always tell you what's wrong with your script. The (number, number) entry tells you where in your script there is a problem. For example:

(23, 5) means that there is a problem on line 23, character 5 (not always; sometimes it is something caused by another error, but it is usually close by and you can spot it)

There are different types of error messages, and you should read them to see what is wrong with your script. THE #1 error message is "unexpected end of file." This means you are missing a {, (, ", or a comma somewhere.
(This post was last modified: 04-10-2011, 09:46 PM by MrBigzy.)
04-10-2011, 04:20 PM
Find
Dalroc Offline
Member

Posts: 57
Threads: 2
Joined: Mar 2011
Reputation: 0
#2
RE: Common Script Errors: Look here first!

Just bumping this to the first page, it's a good read!
04-12-2011, 09:33 PM
Find
ZxBrad Offline
Member

Posts: 140
Threads: 29
Joined: Mar 2011
Reputation: 0
#3
RE: Common Script Errors: Look here first!

I want the player to make a gasping sound. how would i do that.

WARNING: Noob Doesn't Know How To Script.
[Image: xcn384.gif]

04-12-2011, 10:06 PM
Find




Users browsing this thread: 1 Guest(s)