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
Need some help with scripting... new to AMNESIA'S scripting...
xResorx Offline
Junior Member

Posts: 10
Threads: 2
Joined: Jul 2012
Reputation: 0
#1
Need some help with scripting... new to AMNESIA'S scripting...

Hello there, I need some help with a few scripts.

NOTE: Amnesia was capitalized because I do play some other games that allow you to script. However those games use Lua. Quite honestly I can only do basic stuff within the constraints of that game, it has a limited version of the Lua language, but I would be extremely glad if you guys could help me out some.

Okay so heres the situation, Ive just got through testing my custom story (FINALLY, stupid hidden file extensions....) and I have several scripted encounters already. I also have scripts for said encounters. Honestly I have no idea how theyre supposed to be placed in the .hps file. So I went looking in the .hps files of some of the main story maps(Usually how I learn script languages, editing). Perhaps Im not following the pattern right, or maybe my scripts are incorrect in their syntax. So if one of you more experienced coders could take a look and do two things for me Id be eternally grateful. Those two things are:

1.Help me with the correct syntax
2.Tell me how they should go in the .hps folder

SORRY FOR NO SPOILERSSS! Im on a phone and its hard.

So here they are:

Script One- Blows out the lights when the player touches the correct area.
void OnStart()
{
AddEntityCollideCallback("Player", "LightsOut", true);
}

void LightsOut(string &in asParent, string &in asChild, int alState)
{
[SetLampLit("outlamp_1", false, true);
AddTimer("", 2, "Out2");
} ]--This bracketed line is repeated enough times to satisfy my lamp outtage needs. The following repetitions increase only the number behind "outlamp_" and "Out"

after that comes

voidOnEnter()
{
}

voidOnLeave()
{
}

Second script spawns a monster when the player grabs a specific Tenderbox
voidOnStart()
{
SetEntityPlayerInteractCallback("monster_tinderbox", "function", true);


}

void function (string &in entity)
{

SetEntityActive("tinbox_prolwer", true);

Third and final script Id like you guys to look at, slams a door in the players face when they touch an area

void OnStart()
{
AddEntityCollideCallback("Player", "script_slam", true
}

void func_slam(string &in asParent, string %in asChild, int alState)
{
SetSwingDoorClosed("slamdoor1", true, true);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false
PlaySoundEntity("", "react_scare", "Player", 0, false); PlaySound

GiveSanityDamage(5, 0f, true);
}

I do have some basic insight into what each part of the scripts do. Very basic but I can read down and give a pretty accurate guess as to what part of the script executes what action. Please help though. I still have HIGHLY limited knowledge on this.

Thanks in advance guys!
07-29-2012, 05:32 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#2
RE: Need some help with scripting... new to AMNESIA'S scripting...

Before posting I'd like to know if this is just 1 map, or 3 separate maps?

Okay, under the assumption that this is 1 map, here's how it should look:


void OnStart()
{
AddEntityCollideCallback("Player", "LightsOut", true);
SetEntityPlayerInteractCallback("monster_tinderbox", "function", true);
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}

void LightsOut(string &in asParent, string &in asChild, int alState)
{
[SetLampLit("outlamp_1", false, true); ///I don't know what "[]" do or what you're trying to accomplish with them, so I left them alone.
AddTimer("", 2, "Out2");
} ]

void function(string &in asEntity)
{
SetEntityActive("tinbox_prolwer", true);
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("slamdoor1", true, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false
PlaySoundEntity("", "react_scare", "Player", 0, false);
GiveSanityDamage(5, 0f, true);
}

void OnEnter()
{

}

void OnLeave()
{

}

I rate it 3 memes.
(This post was last modified: 07-29-2012, 05:54 AM by Adny.)
07-29-2012, 05:47 AM
Find
xResorx Offline
Junior Member

Posts: 10
Threads: 2
Joined: Jul 2012
Reputation: 0
#3
RE: Need some help with scripting... new to AMNESIA'S scripting...

Yes its one map.

Those brackets were to show a repeated line of code. Because im on a phone and the script extended pretty far. (It was the same line, just different lamps)

So I guess those dividers made out of "/" that the game makers used were just to organize?

What if I go about adding in more stuff? Would it need to be positioned a certain way, or is it just slap it in after the other scripts?
07-29-2012, 08:09 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#4
RE: Need some help with scripting... new to AMNESIA'S scripting...

(07-29-2012, 08:09 AM)xResorx Wrote: Yes its one map.

Those brackets were to show a repeated line of code. Because im on a phone and the script extended pretty far. (It was the same line, just different lamps)

So I guess those dividers made out of "/" that the game makers used were just to organize?

What if I go about adding in more stuff? Would it need to be positioned a certain way, or is it just slap it in after the other scripts?
The "//" (which has to be a minimum of two slashes, but there's no limit) makes the subsequent text (on that same line) "invisible", so to speak. If you're using notepad++ and set it to the C++ language, the text will turn green. It's ideal for organizing and keeping track of what functions do what.

As far as adding more stuff goes, it's pretty straightforward; just make sure that you only have 1 OnStart, OnEnter, and OnLeave. If you have multiple callbacks, put them all under "void OnStart()" (there are a few exceptions as to when you would put callbacks under OnEnter, but it's so rare I won't go into that).

I rate it 3 memes.
07-29-2012, 08:25 AM
Find
xResorx Offline
Junior Member

Posts: 10
Threads: 2
Joined: Jul 2012
Reputation: 0
#5
RE: Need some help with scripting... new to AMNESIA'S scripting...

error main(20,44) : EBR : Expected ")" or ";"


It just changed o.o
(This post was last modified: 07-29-2012, 08:29 AM by xResorx.)
07-29-2012, 08:27 AM
Find
Adny Offline
Posting Freak

Posts: 1,766
Threads: 6
Joined: Mar 2012
Reputation: 173
#6
RE: Need some help with scripting... new to AMNESIA'S scripting...

My apologies; I don't usually let stuff like that slip through Tongue


The 35 refers to the line and the 44 refers to the character. If you looked at the script, that would be the very last line; that means one of the lines wasn't written out correctly. I looked under "func_slam", and there are 2 problems:

The first PlaySoundAtEntity was missing a ");" at the very end, and the second PlaySoundAtEntity was actually spelled as "PlaySoundEntity". Also, the GiveSanityDamage is only supposed to have 1 float (decimal) value, not 2. Here's the revised version of "func_slam":

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("slamdoor1", true, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false):
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}

You can copy/paste in the script (without any of the arguments filled in) from here:

http://wiki.frictionalgames.com/hpl2/amn..._functions

I rate it 3 memes.
07-29-2012, 08:36 AM
Find




Users browsing this thread: 1 Guest(s)