Frictional Games Forum (read-only)

Full Version: multiple script problem!!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi there im kinda new to scripting, but i have managed to learn alot of scripting, but i need help with one thing, this is my script:


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

just a regular key-to-door script, but if i want to put another door script that is just the same, then what do i need to write between these so the game understands that its two different script?? do i need to write ''void..'' and then what?? plz help.
Is this for Penumbra or Amnesia?

Anyways the "AddUseItemCallBack" line is registering a callback to call the function "UsedKeyOnDoor" for key1 and door1.

So, an easy way would be create a second function and register door2 to use that function as the callback.

If this is for Amnesia, the use the custom stories forum for help.
it is for amnesia. and yes i have renamed the doornames and all that, i just need help with this, and this is not just for especially this script, but for all.

if i write the first example script here:

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


<----then do i need to write something special arround this line?? like {} or something like that to hold the two appart? cause i have tried to just start at the line beneath but then the game says :unexpected.. blabla and then ''{''?? how do i write them two next to each other?


void OnStart()
{
AddUseItemCallback("", "awesomekey_2", "awesomedoor_2", "UsedKeyOnDoor", true);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("awesomedoor_2", false, true);
PlaySoundAtEntity("", "unlock_door", "awesomedoor_1", 0, false);
RemoveItem("awesomekey_2");
}
Just add the second Callback in the OnStart function and make a function for the callback, like this:

Code:
void OnStart()
{
AddUseItemCallback("", "awesomekey_1", "awesomedoor_1", "UsedKeyOnDoor1", true);
AddUseItemCallback("", "awesomekey_2", "awesomedoor_2", "UsedKeyOnDoor2", true);
}

void UsedKeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("awesomedoor_1", false, true);
PlaySoundAtEntity("", "unlock_door", "awesomedoor_1", 0, false);
RemoveItem("awesomekey_1");
}

void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("awesomedoor_2", false, true);
PlaySoundAtEntity("", "unlock_door", "awesomedoor_2", 0, false);
RemoveItem("awesomekey_2");
}
thanks a thousand!!!
Hey ive got a similar problem and its really starting to piss me off. ive already done those doors and keys correctly and they work fine, but what do i put after this:

void OnStart()
{
AddUseItemCallback("", "torture_1", "castle_1", "KeyOnDoor1", true);
AddUseItemCallback("", "tomb", "mansion_1", "KeyOnDoor2", true);
}

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

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

void OnLeave()

{
}

when i want to put something else in like an area script or another script that isnt to do with keys and doors, if anyone can help ill be so happy >Sad

Is this for Amnesia custom story development? If so, why the hell it is in OPEN SOURCE COLLABORATION?!
Can Someone help me ?!
i need these two scripts to be in the same file
ive seperated the scripts with this V
----------------------------------------------------------------------
void OnStart()
{
AddEntityCollideCallback("Player", "Jumpscare_1", "Jump1", true, 1);

}
void Jump1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "21_intro_scream.snt", "bro_1", 0, false);
SetEntityActive("bro_1", true);
AddTimer("", 1.0, "scared");
}
void scared(string &in asTimer)
{
PlaySoundAtEntity("", "21_scream10(.ogg)", "Player", 0, false);
SetEntityActive("bro_1", false);
}
-----------------------------------------------------------------------
void OnStart()
{
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}
(06-14-2013, 09:15 PM)5BitHero Wrote: [ -> ]Can Someone help me ?!
i need these two scripts to be in the same file
ive seperated the scripts with this V
----------------------------------------------------------------------
void OnStart()
{
AddEntityCollideCallback("Player", "Jumpscare_1", "Jump1", true, 1);

}
void Jump1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "21_intro_scream.snt", "bro_1", 0, false);
SetEntityActive("bro_1", true);
AddTimer("", 1.0, "scared");
}
void scared(string &in asTimer)
{
PlaySoundAtEntity("", "21_scream10(.ogg)", "Player", 0, false);
SetEntityActive("bro_1", false);
}
-----------------------------------------------------------------------
void OnStart()
{
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}

Why did you bump up a 2 year old threat?
You could instead make a new one!

Script in this spoiler
Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "Jumpscare_1", "Jump1", true, 1);
AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true);
}
void Jump1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "21_intro_scream.snt", "bro_1", 0, false);
SetEntityActive("bro_1", true);
AddTimer("", 1.0, "scared");
}
void scared(string &in asTimer)
{
PlaySoundAtEntity("", "21_scream10(.ogg)", "Player", 0, false);
SetEntityActive("bro_1", false);
}
void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked(asEntity, false, true);
PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
RemoveItem(asItem);
}

Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "Jumpscare_1", "Jump1", true, 1);
    AddUseItemCallback("", "Key", "Door", "UseKeyOnDoor", true); //You can't have this in another OnStart(). Just put the second parameter in the OnStart() to the first one.
}

void Jump1(string &in asParent, string &in asChild, int alState)
{  
    PlaySoundAtEntity("", "21_intro_scream.snt", "bro_1", 0, false);
    SetEntityActive("bro_1", true);
        AddTimer("", 1, "scared"); //No need to add .0 if it's 1, 2, 3 and so on.
}

void scared(string &in asTimer)
{
    PlaySoundAtEntity("", "21_scream.snt", "Player", 0, false); //You have the wrong extension and wrong file name.
    SetEntityActive("bro_1", false);
}

void UseKeyOnDoor(string &in asItem, string &in asEntity)
{
        SetSwingDoorLocked(asEntity, false, true);
        PlaySoundAtEntity("", "unlock_door.snt", asEntity, 0, false);
        RemoveItem(asItem);
}

Y U BUMP THRED?!

Anyway, here's the fixed script. Anything wrong is pinpointed in the script itself.

EDIT:
After re-reading it, it looks like you're going to make a dead body lunge to the Player. Please don't do that. Most people here doesn't like the "Flying Naked Guy" or "Flying Jesus".