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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple script problem!!!
muminmuffin Offline
Junior Member

Posts: 4
Threads: 2
Joined: Feb 2011
Reputation: 0
#1
multiple script problem!!!

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.
02-12-2011, 10:32 PM
Find
Urkle Offline
FG - Associate

Posts: 1,172
Threads: 31
Joined: Jul 2006
Reputation: 21
#2
RE: multiple script problem!!!

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.

Developing away on one of
Multiple Macs running 10.6, 10.7, 10.8, and 10.9.
Linux, 8-core AMD, 8GB RAM, Fedora 18, nVidia 450 1GB
02-12-2011, 10:40 PM
Website Find
muminmuffin Offline
Junior Member

Posts: 4
Threads: 2
Joined: Feb 2011
Reputation: 0
#3
RE: multiple script problem!!!

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");
}
02-12-2011, 10:46 PM
Find
Oscar House Offline
Senior Member

Posts: 302
Threads: 3
Joined: Nov 2010
Reputation: 9
#4
RE: multiple script problem!!!

Just add the second Callback in the OnStart function and make a function for the callback, like this:

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

[Image: 2exldzm.png]
02-12-2011, 10:56 PM
Find
muminmuffin Offline
Junior Member

Posts: 4
Threads: 2
Joined: Feb 2011
Reputation: 0
#5
RE: multiple script problem!!!

thanks a thousand!!!
02-12-2011, 11:02 PM
Find
Fireintex Offline
Junior Member

Posts: 3
Threads: 0
Joined: Nov 2011
Reputation: 0
#6
RE: multiple script problem!!!

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

11-09-2011, 12:01 AM
Find
Tanshaydar Offline
From Beyond

Posts: 3,085
Threads: 17
Joined: Mar 2009
Reputation: 67
#7
RE: multiple script problem!!!

Is this for Amnesia custom story development? If so, why the hell it is in OPEN SOURCE COLLABORATION?!

11-09-2011, 05:38 AM
Website Find
5BitHero Offline
Junior Member

Posts: 1
Threads: 0
Joined: Jun 2013
Reputation: 0
#8
RE: multiple script problem!!!

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
Find
VeNoMzTeamHysterical Offline
Member

Posts: 240
Threads: 36
Joined: Dec 2012
Reputation: 3
#9
RE: multiple script problem!!!

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


http://www.frictionalgames.com/forum/thread-21719.html
Evil Awaking Work In Progress!
Hours Spend 472.
(This post was last modified: 06-14-2013, 10:02 PM by VeNoMzTeamHysterical.)
06-14-2013, 10:01 PM
Website Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#10
RE: multiple script problem!!!

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

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 06-15-2013, 02:27 AM by PutraenusAlivius.)
06-15-2013, 02:23 AM
Find




Users browsing this thread: 1 Guest(s)