Frictional Games Forum (read-only)

Full Version: attach script to another
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey,

i have a problem and i hope you can help me. I want to attach one script in an hps to another but it doesn´t work. Do you may know the solution for my problem?
__________________________________________________________________________________________

void OnStart()

{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}

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


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

PlaySoundAtEntity("", "react_scare", "Player", 0, false);

PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(15.0f, true);
}



{
AddUseItemCallback("", "key_1", "door_1", "open", true);
}

void open(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("key_1");
}

(12-01-2011, 07:37 PM)Ravenskull Wrote: [ -> ]void OnStart()

{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}

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


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

PlaySoundAtEntity("", "react_scare", "Player", 0, false);

PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(15.0f, true);
} <-REMOVE



{ <-REMOVE
AddUseItemCallback("", "key_1", "door_1", "open", true); <-Shouldn't this be in the "void OnStart"?
}

void open(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("key_1");
}
If this doesn't work there is still something wrong that I missed.

Hi,

both should be "On Start". If i take your script with the two removed brackets the door key doesn´t work :/
(12-02-2011, 03:45 PM)Ravenskull Wrote: [ -> ]Hi,

both should be "On Start". If i take your script witch the two removed brackets the door key doesn´t work :/
Does the error say what line is wrong with the script?
Hey,

no there is no error if i try to start the game - ingame it simply sais that " can not use item on this object" if i try to use the key on the door.
______________________________________________________________________________________

This is my whole used modified sript with the removed brackets

void OnStart()

{
AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1);
}

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


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

PlaySoundAtEntity("", "react_scare", "Player", 0, false);

PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(15.0f, true);





AddUseItemCallback("", "key_1", "door_1", "open", true);
}

void open(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "door_1", 0, false);
RemoveItem("key_1");
}
The script seems ok on a quick glance. There is most likely some misnamed entity or something.
I don´t think theres s.th. wrong with the entities, because the two scripts work fine on their own.
This is so f****** disappointing -.-
If I'm not mistaken, you have to make a global.hps
what do you mean with "global.hps" ?

it´s \Amnesia - The Dark Descent\redist\maps\Trip\TripTrip.hps

Trip is the map folder and TripTrip is the name of the map and of the hps file

(12-03-2011, 06:59 PM)Ravenskull Wrote: [ -> ]what do you mean with "global.hps" ?

it´s \Amnesia - The Dark Descent\redist\maps\Trip\TripTrip.hps

Trip is the map folder and TripTrip is the name of the map and of the hps file
global.hps is a script file that allows scripts to be ran through multiple maps. A single mapname.hps can ONLY script what is it that map itself, it cannot carry over to other maps.

Pages: 1 2