Frictional Games Forum (read-only)
Adding multiple scripts together? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Adding multiple scripts together? (/thread-16472.html)



Adding multiple scripts together? - Wrathborn771 - 06-25-2012

Hello,

I'm working on two custom stories for Amnesia, and I really need to know how to put multiple scripts together! Can someone please explain, I haven't found any noob-friendly tutorials after hours of googling. In fact, I haven't found ANY guide on it whatsoever.

And before you ask why I'm working on a custom story if I can't script, here's the answer:
My friend has done the scripting in my stories until last week. He stopped helping me because he has final exams, and it's too much to be handling 2+ stories and final exams at the same time.
I could ofcourse wait a few weeks til' he's done, but I figured it would be much better if I could learn it myself, so I could practise on my own ones.

So, please try to teach me?

-Wrathborn771


RE: Adding multiple scripts together? - Your Computer - 06-25-2012

What do you mean by adding multiple scripts together? Merging two HPS files together? Importing one into the other? Referencing a function from one in another? How to script for Amnesia?


RE: Adding multiple scripts together? - Wrathborn771 - 06-25-2012

(06-25-2012, 12:55 AM)Your Computer Wrote: What do you mean by adding multiple scripts together? Merging two HPS files together? Importing one into the other? Referencing a function from one in another? How to script for Amnesia?
I mean adding two different script-fuctions into the same .hpl file.
For example:

Picking up a key makes a monster spawn (I don't know the script, and I'm too tired to find it)
And I want to add that with another function, which doesn't relate in any way.

And that function is:
Stepping into a area will spawn another monster (again, too tired too look it up)

How do I make those two functions to work together in the same .hps file?

I've tried copy+pasting into the same document and making sure the { and } brackets are in a somewhat logical (for me) order.

Like this:

void OnStart ()
{
one-function);
}
and-it-continues-here);
{
now-the-second-function);
}
and-it-continues-here-aswell
{
and-here-aswell
}

void OnEnter ()

And you know the rest.
I hope I told it in a somewhat non-retard-noob-ish way, and that you can still understand what I'm trying to say.


RE: Adding multiple scripts together? - Your Computer - 06-25-2012

Then you should consider studying:
http://wiki.frictionalgames.com/hpl2/tutorials/script/entihscript_beginner
http://wiki.frictionalgames.com/hpl2/amnesia/script_functions


RE: Adding multiple scripts together? - Wrathborn771 - 06-25-2012

(06-25-2012, 01:25 AM)Your Computer Wrote: Then you should consider studying:
http://wiki.frictionalgames.com/hpl2/tutorials/script/entihscript_beginner
http://wiki.frictionalgames.com/hpl2/amnesia/script_functions
I'v already read those, but I don't find a direct answer. Could you please try to explain atleast?


RE: Adding multiple scripts together? - Damascus - 06-25-2012

Hmm. Maybe this will clear some things up.

void OnStart () ///this is a function, every script inside the brackets runs off this function
{
SetMapDisplayNameEntry("library"); ///these are scripts
AddTimer("ChairThrow", 0.0f, "ChairThrow");
AddUseItemCallback("", "key_laboratory_1", "mansion_7", "unlock", true); ///this script calls a new function, which will start with "void" and get a new pair of brackets
}

void unlock(string &in asItem, string &in asEntity) ///many functions need syntax like this when triggered by a callback
{
SetSwingDoorLocked("mansion_7", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_7", 0, false);
RemoveItem("key_laboratory_1");
}

In the example above, every script in the first function runs as soon as you start the map. Every script in the second function runs when it is triggered. It is callbacks that prepares a trigger to execute scripts.


RE: Adding multiple scripts together? - Wrathborn771 - 06-25-2012

(06-25-2012, 07:00 PM)Damascus Wrote: Hmm. Maybe this will clear some things up.

void OnStart () ///this is a function, every script inside the brackets runs off this function
{
SetMapDisplayNameEntry("library"); ///these are scripts
AddTimer("ChairThrow", 0.0f, "ChairThrow");
AddUseItemCallback("", "key_laboratory_1", "mansion_7", "unlock", true); ///this script calls a new function, which will start with "void" and get a new pair of brackets
}

void unlock(string &in asItem, string &in asEntity) ///many functions need syntax like this when triggered by a callback
{
SetSwingDoorLocked("mansion_7", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_7", 0, false);
RemoveItem("key_laboratory_1");
}

In the example above, every script in the first function runs as soon as you start the map. Every script in the second function runs when it is triggered. It is callbacks that prepares a trigger to execute scripts.
Lemme see if I've gotten this right then..
Everytime you write ´void´ you give it a new pair of brackets? Is that it?
Here's a bit of one of the scripts my friend did for me:


void OnStart()
{
AddEntityCollideCallback("Player", "Jumpscare_1", "Jump1", true, 1);
AddEntityCollideCallback("Player", "jumpscare_2", "Jump2", true, 1);
AddUseItemCallback("", "key_01", "locked_door2", "UsedKeyOnDoor", true);
SetEntityPlayerInteractCallback("key_01", "Key_01", true);
AddUseItemCallback("", "torture_key_1", "torture_door_1", "UsedKeyOnDoor2", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door2", 0, false);
RemoveItem("key_01");
}
void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("torture_door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "torture_door_1", 0, false);
RemoveItem("torture_key_1");
}
void Jump1(string &in asParent, string &in asChild, int alState)
{

Now I accually see it! Brackets surrounding the void-commands?? Is that the only thing you need to think about when putting different functions together in the same file?


RE: Adding multiple scripts together? - Damascus - 06-25-2012

Yep now you're getting it! It's not the only thing to think about, but it's the majority of what you deal with when you're a beginner. I couldn't tell you everything there is to know but you can always look into existing scripts and tutorials as you learn more.


RE: Adding multiple scripts together? - GoranGaming - 06-25-2012

"Im tired to look it up" You need to learn and think creative! Its very easy when you have started to understand the script language


RE: Adding multiple scripts together? - Wrathborn771 - 06-25-2012

(06-25-2012, 08:37 PM)GoranGaming Wrote: "Im tired to look it up" You need to learn and think creative! Its very easy when you have started to understand the script language
Well, it was in the middle of the night, I had been working on mapping the whole day and I went to bed just after posting this thread.