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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding multiple scripts together?
Wrathborn771 Offline
Junior Member

Posts: 45
Threads: 10
Joined: Jun 2012
Reputation: 0
#1
Question  Adding multiple scripts together?

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
06-25-2012, 12:46 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Adding multiple scripts together?

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?

Tutorials: From Noob to Pro
06-25-2012, 12:55 AM
Website Find
Wrathborn771 Offline
Junior Member

Posts: 45
Threads: 10
Joined: Jun 2012
Reputation: 0
#3
RE: Adding multiple scripts together?

(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.
(This post was last modified: 06-25-2012, 01:19 AM by Wrathborn771.)
06-25-2012, 01:17 AM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: Adding multiple scripts together?

Then you should consider studying:
http://wiki.frictionalgames.com/hpl2/tut...t_beginner
http://wiki.frictionalgames.com/hpl2/amn..._functions

Tutorials: From Noob to Pro
06-25-2012, 01:25 AM
Website Find
Wrathborn771 Offline
Junior Member

Posts: 45
Threads: 10
Joined: Jun 2012
Reputation: 0
#5
RE: Adding multiple scripts together?

(06-25-2012, 01:25 AM)Your Computer Wrote: Then you should consider studying:
http://wiki.frictionalgames.com/hpl2/tut...t_beginner
http://wiki.frictionalgames.com/hpl2/amn..._functions
I'v already read those, but I don't find a direct answer. Could you please try to explain atleast?
06-25-2012, 12:31 PM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#6
RE: Adding multiple scripts together?

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.

(This post was last modified: 06-25-2012, 07:02 PM by Damascus.)
06-25-2012, 07:00 PM
Find
Wrathborn771 Offline
Junior Member

Posts: 45
Threads: 10
Joined: Jun 2012
Reputation: 0
#7
RE: Adding multiple scripts together?

(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?
(This post was last modified: 06-25-2012, 07:36 PM by Wrathborn771.)
06-25-2012, 07:35 PM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#8
RE: Adding multiple scripts together?

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.

06-25-2012, 08:07 PM
Find
GoranGaming Offline
Member

Posts: 183
Threads: 30
Joined: Feb 2012
Reputation: 7
#9
RE: Adding multiple scripts together?

"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

Current projects:

The Dark Prison 85 % (Stopped working on this one)

Unnamed Project 7 %
06-25-2012, 08:37 PM
Website Find
Wrathborn771 Offline
Junior Member

Posts: 45
Threads: 10
Joined: Jun 2012
Reputation: 0
#10
RE: Adding multiple scripts together?

(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.
06-25-2012, 09:14 PM
Find




Users browsing this thread: 1 Guest(s)