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


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

Posts: 616
Joined: Mar 2011
Reputation: 8
Post: #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 all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
Common Script Errors: Look here first! - MrBigzy - 04-10-2011 04:20 PM



User(s) browsing this thread: 1 Guest(s)