Frictional Games Forum (read-only)
Another Scripting Problem... - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Another Scripting Problem... (/thread-5003.html)

Pages: 1 2


Another Scripting Problem... - Kyle - 10-10-2010

I once again tried to combine 2 scripts and it failed at working. I tried to make a servant grunt to become active when you went into an area. So I added: AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1); AND void SetEntityActive(servant_grunt, true);

Full script:

////////////////////////////
// Run first time starting map
void OnStart()

{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
AddUseItemCallback("", "Mansion Key", "MansionDoor", "UsedKeyOnDoor", true);
}

void SetEntityActive(servant_grunt, true);
void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{
SetSwingDoorLocked("MansionDoor", false, true);
PlaySoundAtEntity("", "unlock_door" , "MansionDoor", 0, false);
RemoveItem("Mansion Key");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}

I also wanted to point out that I DO NOT want the grunt to become active when I try to open the door... Please try to keep it seperate.


RE: Another Scripting Problem... - Entih - 10-10-2010

Hmm, and where might the function for your callback be? You add it, but you never make it do anything, you see. As such, the activation for the grunt is just kind of sitting out there in the aether where it will never be performed.

You see, anything outside the brackets of a function like 'void OnStart()' and such don't quite do anything. Some variables can be made, but its nothing quite functional for what you want. That's why you create the callback, to create a function which is used when one thing (player) touches another (your area).

A collide function is called like so, and the things to occur go within the brackets:

void CollideFunction(string &in asParent, string &in asChild, int alState)
{
[Stuff That Happens Goes Here...]
}


RE: Another Scripting Problem... - Kyle - 10-10-2010

So it should be like this?

////////////////////////////
// Run first time starting map
void OnStart()

{
AddUseItemCallback("", "Mansion Key", "MansionDoor", "UsedKeyOnDoor", true);
}

void SetEntityActive(servant_grunt, true);
void UsedKeyOnDoor(string &in asItem, string &in asEntity)

{
SetSwingDoorLocked("MansionDoor", false, true);
PlaySoundAtEntity("", "unlock_door" , "MansionDoor", 0, false);
RemoveItem("Mansion Key");
}

{
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
void CollideFunction(string &in asParent, string &in asChild, int alState)

}
void SetEntityActive(servant_grunt, true);



////////////////////////////
// Run when leaving map
void OnLeave()
{

}


RE: Another Scripting Problem... - Chilton - 10-10-2010

Try this:



void OnStart()
{
AddUseItemCallback("", "Mansion Key", "MansionDoor", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player" , "ScriptArea_1" , "CollideRoomTwo" , true, 1);
}

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

void CollideRoomTwo(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt", true);
}

void OnEnter()
{
}

void OnLeave()
{
}



If that doesnt work, its because im half asleep and mistyped. It should work though - Also, your getting the organisation and syntaxing wrong - Just compare your script to my ammended one

EDIT: This should work. I got no errors when i validated it just now


RE: Another Scripting Problem... - Frontcannon - 10-10-2010

Please learn the syntax, the script you just posted will just make your level crash D:


RE: Another Scripting Problem... - Kyle - 10-10-2010

Nope, didn't work. The error message said that "servant_grunt is not declared."


RE: Another Scripting Problem... - Chilton - 10-10-2010

(10-10-2010, 06:05 PM)Kyle Wrote: Nope, didn't work. The error message said that "servant_grunt is not declared."
Sorry
Use it now - I forgot to put markers around it. Its now edited in, and if thats the only error, it will work


RE: Another Scripting Problem... - Frontcannon - 10-10-2010

(10-10-2010, 06:07 PM)Chilton Wrote:
(10-10-2010, 06:05 PM)Kyle Wrote: Nope, didn't work. The error message said that "servant_grunt is not declared."
Sorry
Use it now - I forgot to put markers around it. Its now edited in, and if thats the only error, it will work

I somehow missed your post, I was referring to Kyle's post Blush


RE: Another Scripting Problem... - Chilton - 10-10-2010

(10-10-2010, 06:09 PM)Frontcannon Wrote:
(10-10-2010, 06:07 PM)Chilton Wrote:
(10-10-2010, 06:05 PM)Kyle Wrote: Nope, didn't work. The error message said that "servant_grunt is not declared."
Sorry
Use it now - I forgot to put markers around it. Its now edited in, and if thats the only error, it will work

I somehow missed your post, I was referring to Kyle's post Blush

I figured, based on the buffer between you typing and me posting - Funny thing is you were correct by accident :p


RE: Another Scripting Problem... - Kyle - 10-10-2010

Frostcannon. Actually Chilton really messed up the syntax. Luckly it works, but the monster spawns before I reach the trigger area...