Frictional Games Forum (read-only)
attach script to another - 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: attach script to another (/thread-11603.html)

Pages: 1 2


attach script to another - Ravenskull - 12-01-2011

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");
}




RE: attach script to another - JMFStorm - 12-01-2011

(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.




RE: attach script to another - Ravenskull - 12-02-2011

Hi,

both should be "On Start". If i take your script with the two removed brackets the door key doesn´t work :/



RE: attach script to another - flamez3 - 12-02-2011

(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?


RE: attach script to another - Ravenskull - 12-03-2011

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");
}



RE: attach script to another - Khyrpa - 12-03-2011

The script seems ok on a quick glance. There is most likely some misnamed entity or something.



RE: attach script to another - Ravenskull - 12-03-2011

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 -.-



RE: attach script to another - Statyk - 12-03-2011

If I'm not mistaken, you have to make a global.hps



RE: attach script to another - Ravenskull - 12-03-2011

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




RE: attach script to another - Statyk - 12-03-2011

(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.