Frictional Games Forum (read-only)
Scripts Recollection - 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 Articles (https://www.frictionalgames.com/forum/forum-40.html)
+---- Thread: Scripts Recollection (/thread-5117.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12


RE: Scripts Recollection - jillis - 01-24-2012

(01-24-2012, 03:27 AM)flamez3 Wrote: Oops, use (string &in asEntity) instead ^^
Thanks man it worked!! I really appreciate it! Big Grin Big Grin


RE: Scripts Recollection - mrscoomich - 03-18-2012

(10-20-2010, 02:20 PM)Frontcannon Wrote: Some simple functions covering the basics for the people being completely new to scripting?
Let's see what I can find..

How to make a locked door and a key to unlock it

Spoiler below!

Code:
void OnStart()
{
    AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}

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

What it does:
AddUseItemCallback - calls a function when an item is used on an entity
R01_Key1 - the item used, in this case our key
mansion_1 - the entity the key is used on, the normal mansion door
KeyOnDoor - the function the callback calls (true means to remove it when called once)

SetSwingDoorLocked - locks/unlocks a door, false means to set it NOT locked, and the true is to wether use effects or not
PlaySoundAtEntity - plays a sound at an entity, in this case the "unlocked a door"- sound at mansion_1, our door, the float value is the time it takes to fade in and the true is some strange boolean Big Grin

this one doesnt work. I tried to place it onto my script but it gave me an error...
but its telling me that this : void KeyOnDoor(string &in asItem, string &in asEntity)
is the problem.




RE: Scripts Recollection - Stepper321 - 03-19-2012

(03-18-2012, 05:58 PM)mrscoomich Wrote:
(10-20-2010, 02:20 PM)Frontcannon Wrote: Some simple functions covering the basics for the people being completely new to scripting?
Let's see what I can find..

How to make a locked door and a key to unlock it

Spoiler below!

Code:
void OnStart()
{
    AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}

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

What it does:
AddUseItemCallback - calls a function when an item is used on an entity
R01_Key1 - the item used, in this case our key
mansion_1 - the entity the key is used on, the normal mansion door
KeyOnDoor - the function the callback calls (true means to remove it when called once)

SetSwingDoorLocked - locks/unlocks a door, false means to set it NOT locked, and the true is to wether use effects or not
PlaySoundAtEntity - plays a sound at an entity, in this case the "unlocked a door"- sound at mansion_1, our door, the float value is the time it takes to fade in and the true is some strange boolean Big Grin

this one doesnt work. I tried to place it onto my script but it gave me an error...
but its telling me that this : void KeyOnDoor(string &in asItem, string &in asEntity)
is the problem.
More detail please


RE: Scripts Recollection - mrscoomich - 03-21-2012

(03-19-2012, 05:22 PM)Stepper321 Wrote:
(03-18-2012, 05:58 PM)mrscoomich Wrote:
(10-20-2010, 02:20 PM)Frontcannon Wrote: Some simple functions covering the basics for the people being completely new to scripting?
Let's see what I can find..

How to make a locked door and a key to unlock it

Spoiler below!

Code:
void OnStart()
{
    AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}

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

What it does:
AddUseItemCallback - calls a function when an item is used on an entity
R01_Key1 - the item used, in this case our key
mansion_1 - the entity the key is used on, the normal mansion door
KeyOnDoor - the function the callback calls (true means to remove it when called once)

SetSwingDoorLocked - locks/unlocks a door, false means to set it NOT locked, and the true is to wether use effects or not
PlaySoundAtEntity - plays a sound at an entity, in this case the "unlocked a door"- sound at mansion_1, our door, the float value is the time it takes to fade in and the true is some strange boolean Big Grin

this one doesnt work. I tried to place it onto my script but it gave me an error...
but its telling me that this : void KeyOnDoor(string &in asItem, string &in asEntity)
is the problem.
More detail please





----
Code:
void OnStart()
{
AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}

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


When I copy and paste that (replacing the examples with my entity/ door names),
it says Error( a number, a number)

and when I stare back at my .hps file, it seems that the error told me it was the line where the
void KeyOnDoor(string &in asItem, string &in asEntity)

was placed. i've tried to fix this a couple times and not sure if there is a typo or where to.

why doesnt it work?


RE: Scripts Recollection - flamez3 - 03-21-2012

Is this your whole script. And what is your error say.


RE: Scripts Recollection - mrscoomich - 03-25-2012

Ah my apologies. I forgot to leave the void KeyOnDoor out of the OnStart()
I'm only a beginner in scripting.
Code:
void OnStart()
//IN OnStart
{
AddUseItemCallback("", "R01_Key1", "mansion_1", "KeyOnDoor", true);
}
//OUTSIDE of OnStart
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0.0f, true);
}


^ could you please change it to this? it will seem less complicating. hehe thanks