Frictional Games Forum (read-only)
[SCRIPT] Unexpected end of file error 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Unexpected end of file error problem :( (/thread-24466.html)

Pages: 1 2


RE: Unexpected end of file error problem :( - Romulator - 01-27-2014

*facepalm* how did I not see this before >.>

Isn't it because he is missing the && in the second two?

Try the chasers one above first, then try this:
PHP Code:
void UnlockDoor(string &in asEntityint LeverState)
{
if(
GetLeverState("Lever1") == -1)
&& (
GetLeverState("Lever2") == -1)
&& (
GetLeverState("Lever3") == 1)
&& (
GetLeverState("Lever4") == -1)

{
SetSwingDoorLocked("Door"falsetrue);
PlaySoundAtEntity("""unlock_door.snt""Door"0false);
}


And if that doesn't work, try this:
PHP Code:
void UnlockDoor(string &in asEntityint LeverState)
{
if(
GetLeverState("Lever1") == -1
&& GetLeverState("Lever2") == -1
&& GetLeverState("Lever3") == 1
&& GetLeverState("Lever4") == -1)

{
SetSwingDoorLocked("Door"falsetrue);
PlaySoundAtEntity("""unlock_door.snt""Door"0false);
}




RE: Unexpected end of file error problem :( - ingedoom - 01-28-2014

Btw... I noticed that you do not call your unlockDoor function from anywhere in your code, so that might be the reason that nothing happens, but not the end of file problem which is surely due to bad syntax.

Also follow the second example remulator gave you in the post above this one. The first example has too many parenthesis.

Here is the full code as it compiles for me.. Should compile for you too. When you try to debug, make sure to load your map with a functioning script, so that it will not crash. Then you can use your debug menu to reload the map and see your error without crashes.

Code:
void OnStart()
{
wakeUp();
}

void wakeUp() {
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(10); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(0, 2);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.5, 2);
SetPlayerCrouching(true); // Simulates being on the ground
PlayMusic("18_amb.ogg", true, 1, 4, 1, true);
AddEntityCollideCallback("Player", "AreaCollide", "EventCollide", true, 1);
AddTimer("trig1", 11.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

void beginStory(string &in asTimer) {
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
SetPlayerLampOil(29);
GiveSanityDamage(80, false);
GivePlayerDamage(30 , "false" , false, false);
SetPlayerMoveSpeedMul(0.56f);
SetPlayerRunSpeedMul(0);
//SetPlayerLookSpeedMul(0.5);
AddUseItemCallback("", "HollowNeedle", "CellDoor", "UseHollowNeedleOnDoor", true);
}

void UseHollowNeedleOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("CellDoor", false, true);
PlaySoundAtEntity("", "unlock_door.ogg", asEntity, 0, false);
GiveSanityBoostSmall();
RemoveItem(asItem);
}

void EventCollide(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("CellGuardGrunt", true);
AddEnemyPatrolNode("CellGuardGrunt", "Node_1",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_4",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_6",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_10",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_15",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_18",0.001f, "");
}


void UnlockDoor(string &in asEntity, int LeverState)
{
        if(GetLeverState("Lever1") == -1
        && GetLeverState("Lever2") == -1
        && GetLeverState("Lever3") == 1
        && GetLeverState("Lever4") == -1)

        {
                SetSwingDoorLocked("Door", false, true);
                PlaySoundAtEntity("", "unlock_door.snt", "Door", 0, false);
        }
}



RE: Unexpected end of file error problem :( - Radical Batz - 01-28-2014

(01-28-2014, 11:31 AM)ingedoom Wrote: Btw... I noticed that you do not call your unlockDoor function from anywhere in your code, so that might be the reason that nothing happens, but not the end of file problem which is surely due to bad syntax.

Also follow the second example remulator gave you in the post above this one. The first example has too many parenthesis.

Here is the full code as it compiles for me.. Should compile for you too. When you try to debug, make sure to load your map with a functioning script, so that it will not crash. Then you can use your debug menu to reload the map and see your error without crashes.

Code:
void OnStart()
{
wakeUp();
}

void wakeUp() {
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(10); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(0, 2);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.5, 2);
SetPlayerCrouching(true); // Simulates being on the ground
PlayMusic("18_amb.ogg", true, 1, 4, 1, true);
AddEntityCollideCallback("Player", "AreaCollide", "EventCollide", true, 1);
AddTimer("trig1", 11.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

void beginStory(string &in asTimer) {
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
SetPlayerLampOil(29);
GiveSanityDamage(80, false);
GivePlayerDamage(30 , "false" , false, false);
SetPlayerMoveSpeedMul(0.56f);
SetPlayerRunSpeedMul(0);
//SetPlayerLookSpeedMul(0.5);
AddUseItemCallback("", "HollowNeedle", "CellDoor", "UseHollowNeedleOnDoor", true);
}

void UseHollowNeedleOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("CellDoor", false, true);
PlaySoundAtEntity("", "unlock_door.ogg", asEntity, 0, false);
GiveSanityBoostSmall();
RemoveItem(asItem);
}

void EventCollide(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("CellGuardGrunt", true);
AddEnemyPatrolNode("CellGuardGrunt", "Node_1",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_4",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_6",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_10",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_15",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_18",0.001f, "");
}


void UnlockDoor(string &in asEntity, int LeverState)
{
        if(GetLeverState("Lever1") == -1
        && GetLeverState("Lever2") == -1
        && GetLeverState("Lever3") == 1
        && GetLeverState("Lever4") == -1)

        {
                SetSwingDoorLocked("Door", false, true);
                PlaySoundAtEntity("", "unlock_door.snt", "Door", 0, false);
        }
}

How am I going to make the puzzle work and the door open after you do the lever puzzle, I've tried everything to make it work but nothing happens, and what do you mean there is no code foe the door, the is one "the unlock door one I guess" if not then pls tell


RE: Unexpected end of file error problem :( - ingedoom - 01-28-2014

Lever entities have a setting called "PlayerInteractCallback"; here you put a function name like "InteractLever"

Now some code
Code:
void InteractLever() {

if(LeverPuzzleSolved())
SetSwingDoorLocked("Door", false, true);
}

bool LeverPuzzleSolved() {

if (GetLeverState("Lever1") == -1
&& GetLeverState("Lever2") == -1
&& GetLeverState("Lever3") == 1
&& GetLeverState("Lever4") == -1)
return true;
else
return false;
}

This should unlock a door when the levers are set correctly.


RE: Unexpected end of file error problem :( - Radical Batz - 01-28-2014

should I put that in void on start?, because I don't know where I should exactly put it, here is my hps file

Code:
void OnStart()
{
wakeUp();
}

void wakeUp() {
FadeOut(0); // Instantly fades the screen out. (Good for starting the game)
FadeIn(10); // Amount of seconds the fade in takes
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(0, 2);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220); // "Tilts" the players head
FadeRadialBlurTo(0.5, 2);
SetPlayerCrouching(true); // Simulates being on the ground
PlayMusic("18_amb.ogg", true, 1, 4, 1, true);
AddEntityCollideCallback("Player", "AreaCollide", "EventCollide", true, 1);
AddTimer("trig1", 11.0f, "beginStory"); // Change '11.0f' to however long you want the 'unconciousness' to last
}

void beginStory(string &in asTimer) {
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33); // Change all settings to defaults
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
SetPlayerLampOil(29);
GiveSanityDamage(80, false);
GivePlayerDamage(30 , "false" , false, false);
SetPlayerMoveSpeedMul(0.56f);
SetPlayerRunSpeedMul(0);
//SetPlayerLookSpeedMul(0.5);
AddUseItemCallback("", "HollowNeedle", "CellDoor", "UseHollowNeedleOnDoor", true);
}

void UseHollowNeedleOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("CellDoor", false, true);
PlaySoundAtEntity("", "unlock_door.ogg", asEntity, 0, false);
GiveSanityBoostSmall();
RemoveItem(asItem);
}

void EventCollide(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("CellGuardGrunt", true);
AddEnemyPatrolNode("CellGuardGrunt", "Node_1",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_4",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_6",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_10",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_15",0.001f, "");
AddEnemyPatrolNode("CellGuardGrunt", "Node_18",0.001f, "");
}


void UnlockDoor(string &in asEntity, int LeverState)
{
        if(GetLeverState("Lever1") == -1
        && GetLeverState("Lever2") == -1
        && GetLeverState("Lever3") == 1
        && GetLeverState("Lever4") == -1)

        {
                SetSwingDoorLocked("Door", false, true);
                PlaySoundAtEntity("", "unlock_door.snt", "Door", 0, false);
        }
}



RE: Unexpected end of file error problem :( - ingedoom - 01-28-2014

(01-28-2014, 05:39 PM)Badcat5550 Wrote: should I put that in void on start?, because I don't know where I should exactly put it, here is my hps file

I think you should be fine you just replace it with the current UnlockDoor function you made.

Please let me know if you get any errors and post the debug info.


RE: Unexpected end of file error problem :( - Radical Batz - 01-28-2014

(01-28-2014, 05:47 PM)ingedoom Wrote:
(01-28-2014, 05:39 PM)Badcat5550 Wrote: should I put that in void on start?, because I don't know where I should exactly put it, here is my hps file

I think you should be fine you just replace it with the current UnlockDoor function you made.

Please let me know if you get any errors and post the debug info.

It's not getting me an error but the lever puzzle is not working and won't unlock the door :/


RE: Unexpected end of file error problem :( - ingedoom - 01-28-2014

To help you further I will need your custom story.

The only advice I can give is to have a look at this
And make sure to use the void AddDebugMessage(string& asString, bool abCheckForDuplicates); to debug your code.