05-23-2012, 06:00 PM
From now on, i am gonna look at scripting errors and fixes and put them here. Cause lately, i have seen many noobs posting the same error over and over again. It would be great if this ever get's stickied. But let's get this done. So, if you, the users of the forum, or I fix errors, they will get put here. Later, when i have enough, i will still update this, but i will remove these sentences and remove the [WIP] in front.
1. Am i capable of making a CS ?
A question you should ask yourself when beginning creating custom stories for the FIRST time!.
How good are you at scripting and mapping? That will determine what level of difficulty there is to do anything.
If you are completely noobish at scripting, then you better look at tutorials before you attempt to do anything scripting related, and then practice your syntax and stuff without getting too complicated in your attempts. Trust me, scripting, is not an easy task, mind you, and it took me a lot of time to understand what I was doing and clean up my scripting.
You should always start small. Open up a map that Frictional Games map. Look at how they laid out their map. Then, make a room in the LevelEditor. Don't add any scripting things, just make a room and get it playable so you can move around and interact with objects. Just try to make a great atmosphere.
When scripting, the same principle applies. Think small scale for the beginning. Make a key that can open a door. Have a door that slams shut when you approach it, etc. They are not hard to implement, you just need to know how to begin. You'll receive a lot of errors when scripting, it's natural, you just have to know how to debug them. We can help with that.
Check the Frictional Games wiki for some tutorials. I'll link a few handy ones that I like:
Level Editor, the Basics
http://wiki.frictionalgames.com/hpl2/tut...tutorial_1
Light Tutorial (this one nobody seems to follow, but it's super important!
http://wiki.frictionalgames.com/hpl2/tut...tutorial_2
Adding Water
http://wiki.frictionalgames.com/hpl2/tut...tutorial_4
Intro to Scripting
http://wiki.frictionalgames.com/hpl2/tut...t_beginner
Beginning to Script
http://wiki.frictionalgames.com/hpl2/tut...y_tutorial
Amnesia Script Functions List (every function that you can use in your scripts to make things happen in game!)
http://wiki.frictionalgames.com/hpl2/amn..._functions
Hope these resources help you. Good luck on your creation!
Posted by: Putmalk. Post Thread
2. The unexpected end of file
This is an error mostly comes. But what does it mean? It will always display the last line of the code. And this can be really hard to find in a huge script. Lets pick a example script. Where the problem is at.
I chose it from this thread.
HEY! What is the problem of the code?!
Oh, hey sorry, haha. The problem of this code is mostly a missing " at the end of a name. For example. There is a " missing at line 11. But it displays line 18 on here! That's cause it can't find the end of it! So it snaps to the last line of code to find the ending ".
I fixed the code here, now it should work!
3. How to set a lantern with almost no/no oil in it?
This is a really simple answer. At the start of your map, put this code in:
DO NOT PUT THIS ON OnEnter(){} AS THIS WILL DO IT EVERYTIME YOU ENTER THE MAP.
4. ERR: 'Doorfalls' is not declared
Taken from this thread + edited
If it gives this error, it's pretty obvious, the game does NOT know when to activate the script, so it doesn't work. Lets create one when it activates at a script area!
Put a script area in your map with your own specified name.
I have given mine a simple name; Area1
Now, lets Script it, in void OnStart() { edit/enter the code this way!
And, save and start, it works now!
I will not paste the code here, because Typing will let you learn.
Wow, this editor keeps screwing things up! It keeps adding [align=webkit-auto] and everywhere!
1. Am i capable of making a CS ?
Spoiler below!
A question you should ask yourself when beginning creating custom stories for the FIRST time!.
How good are you at scripting and mapping? That will determine what level of difficulty there is to do anything.
If you are completely noobish at scripting, then you better look at tutorials before you attempt to do anything scripting related, and then practice your syntax and stuff without getting too complicated in your attempts. Trust me, scripting, is not an easy task, mind you, and it took me a lot of time to understand what I was doing and clean up my scripting.
You should always start small. Open up a map that Frictional Games map. Look at how they laid out their map. Then, make a room in the LevelEditor. Don't add any scripting things, just make a room and get it playable so you can move around and interact with objects. Just try to make a great atmosphere.
When scripting, the same principle applies. Think small scale for the beginning. Make a key that can open a door. Have a door that slams shut when you approach it, etc. They are not hard to implement, you just need to know how to begin. You'll receive a lot of errors when scripting, it's natural, you just have to know how to debug them. We can help with that.
Check the Frictional Games wiki for some tutorials. I'll link a few handy ones that I like:
Level Editor, the Basics
http://wiki.frictionalgames.com/hpl2/tut...tutorial_1
Light Tutorial (this one nobody seems to follow, but it's super important!
http://wiki.frictionalgames.com/hpl2/tut...tutorial_2
Adding Water
http://wiki.frictionalgames.com/hpl2/tut...tutorial_4
Intro to Scripting
http://wiki.frictionalgames.com/hpl2/tut...t_beginner
Beginning to Script
http://wiki.frictionalgames.com/hpl2/tut...y_tutorial
Amnesia Script Functions List (every function that you can use in your scripts to make things happen in game!)
http://wiki.frictionalgames.com/hpl2/amn..._functions
Hope these resources help you. Good luck on your creation!
Posted by: Putmalk. Post Thread
2. The unexpected end of file
Spoiler below!
This is an error mostly comes. But what does it mean? It will always display the last line of the code. And this can be really hard to find in a huge script. Lets pick a example script. Where the problem is at.
I chose it from this thread.
Code:
void OnStart ()
{
AddUseItemCallback("", "key1", "mansion_1", "KeyOnDoor", true);
SetEntityPlayerInteractCallback("key1", "ActivateMonster", true);
}
void KeyOnDoor(string &in asItem, string &in asEntity) {
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
RemoveItem("key1);
}
void ActivateMonster(string &in asItem) {
SetEntityActive("morso1", true);
AddEnemyPatrolNode("morso1", "PathNodeArea_1", 0, "Idle");
AddEnemyPatrolNode("morso1", "PathNodeArea_2", 0, "Idle");
}
HEY! What is the problem of the code?!
Oh, hey sorry, haha. The problem of this code is mostly a missing " at the end of a name. For example. There is a " missing at line 11. But it displays line 18 on here! That's cause it can't find the end of it! So it snaps to the last line of code to find the ending ".
Code:
RemoveItem("key1");
I fixed the code here, now it should work!
3. How to set a lantern with almost no/no oil in it?
Spoiler below!
This is a really simple answer. At the start of your map, put this code in:
Code:
SetPlayerLampOil(10);
DO NOT PUT THIS ON OnEnter(){} AS THIS WILL DO IT EVERYTIME YOU ENTER THE MAP.
4. ERR: 'Doorfalls' is not declared
Spoiler below!
Taken from this thread + edited
Code:
void DoorFalls() //<>
{
SetEntityActive("servant_brute_1", true);
SetEnemyDisableTriggers("servant_brute_1", true);
AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 1, "idle");
} //
If it gives this error, it's pretty obvious, the game does NOT know when to activate the script, so it doesn't work. Lets create one when it activates at a script area!
Put a script area in your map with your own specified name.
I have given mine a simple name; Area1
Now, lets Script it, in void OnStart() { edit/enter the code this way!
And, save and start, it works now!
I will not paste the code here, because Typing will let you learn.
Wow, this editor keeps screwing things up! It keeps adding [align=webkit-auto] and everywhere!