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


Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting mistakes fixed!
Stepper321 Offline
Senior Member

Posts: 263
Threads: 26
Joined: Nov 2011
Reputation: 8
#1
Scripting mistakes fixed!

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 ?
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[Image: buddy_offline.gif]. 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.
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 ".
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:
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

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.
[Image: zglo8.png]

I have given mine a simple name; Area1

Now, lets Script it, in void OnStart() { edit/enter the code this way!
[Image: zaIzc.png]
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!
(This post was last modified: 05-31-2012, 01:57 PM by Stepper321.)
05-23-2012, 06:00 PM
Find
Aresak Offline
Junior Member

Posts: 26
Threads: 1
Joined: May 2012
Reputation: 0
#2
RE: Scripting mistakes fixed!

Censore your second word Big Grin Modarators hate it Big Grin

My Custom Maps:
Black Mirror
--------
I can scripting, editing and more for you.
05-23-2012, 06:06 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#3
RE: Scripting mistakes fixed!

I like the ideas of these threads. But the problem is, when they're lodged into sub-forums, will the people who need to see them actually see them?

05-24-2012, 04:12 AM
Find
Stepper321 Offline
Senior Member

Posts: 263
Threads: 26
Joined: Nov 2011
Reputation: 8
#4
RE: Scripting mistakes fixed!

(05-24-2012, 04:12 AM)Putmalk Wrote: I like the ideas of these threads. But the problem is, when they're lodged into sub-forums, will the people who need to see them actually see them?

I have no idea, but this is not for the Develepmont support. This is for help, so it has to be in the articles. It would be great tough if this was in the Development support.

Signature to awesome to be displayed.
05-24-2012, 09:25 AM
Find
Stepper321 Offline
Senior Member

Posts: 263
Threads: 26
Joined: Nov 2011
Reputation: 8
#5
RE: Scripting mistakes fixed!

ADDED A NEW ARTICLE;
ERR: 'Doorfalls' is not declared

Signature to awesome to be displayed.
05-31-2012, 01:43 PM
Find




Users browsing this thread: 3 Guest(s)