Frictional Games Forum (read-only)
Problem when loading map - 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: Problem when loading map (/thread-6771.html)

Pages: 1 2


Problem when loading map - Viperdream - 03-02-2011

When I try to load my map, I get this error:
Fatal Error: Unexpected end 24,5$

I checked 24,5 and it should be fine.

I'm pretty new to programming so any help is welcome Smile

Spoiler below!
void OnLeverStateChange(string &in EntityName, int alState)
{
if (alState == 0)
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
}
void OnStart()
{
PlayMusic("01_amb_darkness.ogg, false, 1.0f, 0.5f, 10, false)
}

void SetEntityConnectionStateChangeCallback(leverbooks_01, OnLeverStateChange);
//===========================================
// This runs when the player enters the map
void OnEnter()
{
}

//===========================================
// This runs when the player leaves the map
void OnLeave()
{
StopMusic(0.5f, 1);
}



RE: Problem when loading map - Oscar House - 03-02-2011

Here is where your problem is:
Spoiler below!
void OnLeverStateChange(string &in EntityName, int alState)
{
if (alState == 0)
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
}
void OnStart()
{
PlayMusic("01_amb_darkness.ogg, false, 1.0f, 0.5f, 10, false)
}

void SetEntityConnectionStateChangeCallback(leverbooks_01, OnLeverStateChange);
//===========================================
// This runs when the player enters the map
void OnEnter()
{
}

//===========================================
// This runs when the player leaves the map
void OnLeave()
{
StopMusic(0.5f, 1);
}
You shouldn't put it as a function, instead place it inside Onstart(), like this:
Spoiler below!
void OnLeverStateChange(string &in EntityName, int alState)
{
if (alState == 0)
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door", "mansion_1", 0, false);
}
void OnStart()
{
PlayMusic("01_amb_darkness.ogg", false, 1.0f, 0.5f, 10, false);
SetEntityConnectionStateChangeCallback("leverbooks_01", "OnLeverStateChange");
}

//===========================================
// This runs when the player enters the map
void OnEnter()
{
}

//===========================================
// This runs when the player leaves the map
void OnLeave()
{
StopMusic(0.5f, 1);
}

You also missed some quotation marks and a semicolon from there, I added those as well. See how it works, though I suspect there might still be something I missed.


RE: Problem when loading map - Viperdream - 03-02-2011

The map loads now.

But the lever won't work :<


RE: Problem when loading map - nkmol - 03-02-2011

Try to put the connectioncallback at the entity tab of the lever in the level editor.


RE: Problem when loading map - Pandemoneus - 03-02-2011

Check the test map in my sig, it has a working lever.


RE: Problem when loading map - nkmol - 03-02-2011

Sorry try this. And alState == 0 would be neutral, try to change it to -1 or 1

Code:
Void OnLeverStateChange(string &in EntityName, int alState
{
    if (alState == 0)
    {
    SetSwingDoorLocked("mansion_1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0, false);
    }
}



RE: Problem when loading map - Viperdream - 03-03-2011

Tried the script in Pandemoneus map and also tried the script nkmol suggested me

Still won't work :<

This is my current script:
Spoiler below!
void OnStart()
{
SetEntityConnectionStateChangeCallback("leverbooks_01", "StateChangeLever");

AddEntityCollideCallback("Player", "LetterArea_01", "Collide_Area", true, 1);
}
void StateChangeLever(string &in asEntity, int alState)
{
AddDebugMessage("called StateChangeLever", false);

if(alState == 1){
SetLeverStuckState(asEntity, 1, true);
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0, false);
PlayMusic("010_puzzle01.ogg", false, 1.0f, 4.0f, 3, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0, false);
}
}
void Collide_Area(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("note_letter_1", true); //makes letter appear on the floor near the door
}

//===========================================
// This runs when the player enters the map
void OnEnter()
{
}

//===========================================
// This runs when the player leaves the map
void OnLeave()
{
StopMusic(0.5f, 1);
}



RE: Problem when loading map - Nye - 03-04-2011

(03-03-2011, 08:33 PM)Viperdream Wrote: Tried the script in Pandemoneus map and also tried the script nkmol suggested me

Still won't work :<

This is my current script:
Spoiler below!
void OnStart()
{
SetEntityConnectionStateChangeCallback("leverbooks_01", "StateChangeLever");

AddEntityCollideCallback("Player", "LetterArea_01", "Collide_Area", true, 1);
}
void StateChangeLever(string &in asEntity, int alState)
{
AddDebugMessage("called StateChangeLever", false);

if(alState == 1){
SetLeverStuckState(asEntity, 1, true);
SetSwingDoorLocked("mansion_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0, false);
PlayMusic("010_puzzle01.ogg", false, 1.0f, 4.0f, 3, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_1", 0, false);
}
}
void Collide_Area(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("note_letter_1", true); //makes letter appear on the floor near the door
}

//===========================================
// This runs when the player enters the map
void OnEnter()
{
}

//===========================================
// This runs when the player leaves the map
void OnLeave()
{
StopMusic(0.5f, 1);
}

Specifically, in-game - what works and what doesn't work?


RE: Problem when loading map - Viperdream - 03-04-2011

Everything in the script works. Except for the lever. When I try it, nothing happens. I can move it up or down but doesn't stay stuck or anything and activates nothing.

Do I have to do anything in the Level Editor? It's on the same settings as in Pandemoneus' map


RE: Problem when loading map - Pandemoneus - 03-04-2011

If you use that book lever, let me take a look at the offcial maps, I will edit this post soon.

[edit]
The developers made it a bit different for that.
They created a script area in front of the book (in the direction you pull it) and made a normal EntityCollideCallback with the book.
Code:
for(int i=1;i<=3;i++) AddEntityCollideCallback("SecretBook_"+i, "AreaSecretBook_"+i, "CollideSecretBook", false, 0);    //Pull books to reveal room
(Use
Code:
AddEntityCollideCallback("leverbooks_01", "NameOfYourScriptAreaHere", "NameOfYourCollideCallbackHere", false, 0);
for your script)

In that callback function they got a
Code:
SetPropObjectStuckState(asParent, 1);
which makes the book unmoveable (change asParent to "leverbooks_01" if you are not completly sure what this does).