Frictional Games Forum (read-only)
HPS script issue [SOLVED] - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: HPS script issue [SOLVED] (/thread-6216.html)



HPS script issue [SOLVED] - Devil Dogs SF - 01-15-2011

Hiya, I am trying to make a Custom Story, but unfortunately I kinda suck at scripting...

When I try to load the map in game it works fine, although with my HPS file in the story folder it give me a fatal error and crashes the game.

Could someone please take a look at this and see what the issue is, as I can't seem to find any info on it:


void OnStart()
{
AddUseItemCallback("", "key_tomb_rusty_1", "metal_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "metal_1", 0.0f, true);
}

AddUseItemCallback("", "key_torture_chamber_1", "prison_1", "KeyOnDoor", true);
}

void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "prison_1", 0.0f, true);
}


RE: HPS script issue - Andross - 01-15-2011

(01-15-2011, 05:29 AM)Devil Dogs SF Wrote: AddUseItemCallback("", "key_torture_chamber_1", "prison_1", "KeyOnDoor", true);
}
This call needs to be inside a function; propably OnStart().
Also, the closing brace in the following line must go.

Quote:void KeyOnDoor(string &in asItem, string &in asEntity)
...
void KeyOnDoor(string &in asItem, string &in asEntity)
You can't have two functions with the same name and the same parameters.

Btw.: If you set up a dev environment, the game will actually give you a rather helpful error message instead of just crashing.


RE: HPS script issue - Devil Dogs SF - 01-15-2011

I'm still doing something wrong here, don't exactly know what. I probably messed it up in this failed fix I just tried, I still don't understand scripting at all:


Quote:void OnStart(AddUseItemCallback("", "key_tomb_rusty_1", "metal_1", "KeyOnDoor1", true); )
{

void KeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("metal_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "metal_1", 0.0f, true);
RemoveItem("key_tomb_rusty_1");
}

void OnStart(AddUseItemCallback("", "key_torture_chamber_1", "prison_1", "KeyOnDoor2", true); )
{

}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("prison_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "prison_1", 0.0f, true);
RemoveItem("key_torture_chamber_1");
}

void OnStart(AddUseItemCallback("", "key_tower_1", "hatch_ceiling_1", "KeyOnDoor3", true); )
{


void KeyOnDoor3(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("hatch_ceiling_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "hatch_ceiling_1", 0.0f, true);
RemoveItem("key_tower_1");
}

Sorry if this is something super simple, but I am thoroughly confused...Sad


RE: HPS script issue - Andross - 01-15-2011

This way it is syntactically correct; don't know if it's functional, though.
I would suggest some basic programming tutorial. I believe that FrictionalGames suggest to start with JavaScript, as it is similar to AngelScript.

Code:
void OnStart()
{
    AddUseItemCallback("", "key_tomb_rusty_1", "metal_1", "KeyOnDoor1", true);
    AddUseItemCallback("", "key_torture_chamber_1", "prison_1", "KeyOnDoor2", true);
    AddUseItemCallback("", "key_tower_1", "hatch_ceiling_1", "KeyOnDoor3", true);
}

void KeyOnDoor1(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("metal_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "metal_1", 0.0f, true);
    RemoveItem("key_tomb_rusty_1");
}

void KeyOnDoor2(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("prison_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "prison_1", 0.0f, true);
    RemoveItem("key_torture_chamber_1");
}

void KeyOnDoor3(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("hatch_ceiling_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "hatch_ceiling_1", 0.0f, true);
    RemoveItem("key_tower_1");
}



RE: HPS script issue - Devil Dogs SF - 01-15-2011

Thanks, works great. I'll take a look at JavaScript and get familiar with it so I don't feel helplessly confused again when I attempt more scripts.


RE: HPS script issue - Seragath - 01-15-2011

Please change the thread to [Solved] example: "HPS script issue [Solved]"