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


Post Reply 
 
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Didn't Work...
Author Message
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #1
Sad Script Didn't Work...

Here's the script... I tried to combine two scripts for a locked door and for another door that is supposed to shut, but it wouldn't let me load the level.

void OnStart()

{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("cellar_wood01_1", true, true);
GiveSanityDamage(25, true);
}

{
AddUseItemCallback("", "awesomekey_2" , "lockedcellardoor1" , "UsedKeyOnDoor" , true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("lockedcellardoor1" , false, true);
PlaySoundAtEntity("", "unlock_door" , "lockedcellardoor1" , 0, false);
RemoveItem(awesomekey_2);
}

void OnEnter()
{

}

void OnLeave()
{

10-10-2010 01:17 AM
Find all posts by this user Quote this message in a reply
Neurological Offline
Member

Posts: 71
Joined: Sep 2010
Reputation: 1
Post: #2
RE: Script Didn't Work...

I'm not a script expert but I think you missed the closing branch on OnLeave, and maybe you should add:

AddUseItemCallback("", "awesomekey_2" , "lockedcellardoor1" , "UsedKeyOnDoor" , true);

under OnStart right after:

AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);

So in the end the full script would look like this:

void OnStart()

{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
AddUseItemCallback("", "awesomekey_2" , "lockedcellardoor1" , "UsedKeyOnDoor" , true);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("cellar_wood01_1", true, true);
GiveSanityDamage(25, true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("lockedcellardoor1" , false, true);
PlaySoundAtEntity("", "unlock_door" , "lockedcellardoor1" , 0, false);
RemoveItem(awesomekey_2);
}

void OnEnter()
{

}

void OnLeave()
{

}

Neurological - Music Entertainment
http://www.neuro-lab.net
10-10-2010 01:35 AM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #3
RE: Script Didn't Work...

Nope, didn't work Sad

The error says:

FATAL ERROR: Could not load script file 'custom_stories/Exploration/maps/ch01/C:/Program Files(x86)/Steam/SteamApps/common/amnesia the dark descent/custom_stories/Exploration/Maps/ch01/Exploration02.hps'! main (18, 12) : ERR: 'awesomekey_2' is not declared

10-10-2010 02:39 AM
Find all posts by this user Quote this message in a reply
Neurological Offline
Member

Posts: 71
Joined: Sep 2010
Reputation: 1
Post: #4
RE: Script Didn't Work...

(10-10-2010 02:39 AM)Kyle Wrote:  Nope, didn't work Sad

The error says:

FATAL ERROR: Could not load script file 'custom_stories/Exploration/maps/ch01/C:/Program Files(x86)/Steam/SteamApps/common/amnesia the dark descent/custom_stories/Exploration/Maps/ch01/Exploration02.hps'! main (18, 12) : ERR: 'awesomekey_2' is not declared

Try this:

void OnStart()

{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
AddUseItemCallback("", "awesomekey_2" , "lockedcellardoor1" , "UsedKeyOnDoor" , true);
}

void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("cellar_wood01_1", true, true);
GiveSanityDamage(25, true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    
    SetSwingDoorLocked(asEntity, false, true);
    SetLevelDoorLocked(asEntity, false);
    
    PlaySoundAtEntity("unlocksound", "unlock_door.snt", asEntity, 0.0f, false);
    
  RemoveItem(asItem);
}

void OnEnter()
{

}

void OnLeave()
{

}

Neurological - Music Entertainment
http://www.neuro-lab.net
10-10-2010 02:46 AM
Find all posts by this user Quote this message in a reply
Kyle Offline
Posting Freak

Posts: 911
Joined: Sep 2010
Reputation: 7
Post: #5
RE: Script Didn't Work...

Thanks very much! It works perfectly! Big Grin

10-10-2010 01:33 PM
Find all posts by this user Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)