Frictional Games Forum (read-only)

Full Version: What is wrong with this script! (SOLVED)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi.

Im trying to get the player look at something when he enters a specific area.
But the problem is that im a totally noob at scripting so could somebody see what is wrong with my script?

If you find out whats wrong could you please post the entire fixed script?

Here is the full script:

////////////////////////////
// Run first time start[/color]ing map
void OnStart()
{
AddEntityCollideCallback("Player", "Scare1", "LookAtDoor", true, 0);
AddUseItemCallback("", "Key1", "Unlock1", "UsedKeyOnDoor1", true);
FadeOut(0);
FadeIn(20);
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220);
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true);
AddTimer("trig1", 11.0f, "beginStory");
}

void beginStory(string &in asTimer)
{
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33);
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

void UsedKeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Unlock1", false, true);
PlaySoundAtEntity("", "unlock_door", "Unlock1", 0, false);
RemoveItem("Key1");
PlayMusic("02_puzzle.ogg", false, 0.7, 0.1, 10, true);
RemoveItem("Key1");
GiveSanityBoost();
}

void Lookatdoor(string &in asTimer)
{
if(asTimer == "Lookatdoor_01")
{
StartPlayerLookAt("castle_1",2.0f,5.0f,"");
AddTimer("Lookatdoor_02",1.5f,"Lookatdoor");
}

if(asTimer == "Lookatdoor_02")
{
StopPlayerLookAt();
}
}

// Run when entering map
void OnEnter()
{
PlayMusic("27_paper_daniel01.ogg", true, 1.0f, 0, 0, true);
}


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

}
StartPlayerLookAt("castle_1", 4, 100, "");
Try this. And make sure castle_1 is a lookable object Tongue
All the stuff in scripts is case-sensitive. The script probably doesn't work because when the player collides with the area, it calls a funtion named 'LookAtDoor' but your function is named 'Lookatdoor'. I fixed it and the whole script is below.
I'm also concerned about the 'if(asTimer == "Lookatdoor_01")' because you apparently don't have a function that adds a timer like that but test it nevertheless, it might work now.

Code:
////////////////////////////
// Run first time start[/color]ing map
void OnStart()
{
AddEntityCollideCallback("Player", "Scare1", "LookAtDoor", true, 0);
AddUseItemCallback("", "Key1", "Unlock1", "UsedKeyOnDoor1", true);
FadeOut(0);
FadeIn(20);
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220);
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true);
AddTimer("trig1", 11.0f, "beginStory");
}

void beginStory(string &in asTimer)
{
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33);
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

void UsedKeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Unlock1", false, true);
PlaySoundAtEntity("", "unlock_door", "Unlock1", 0, false);
RemoveItem("Key1");
PlayMusic("02_puzzle.ogg", false, 0.7, 0.1, 10, true);
RemoveItem("Key1");
GiveSanityBoost();
}

void LookAtDoor(string &in asTimer)
{
if(asTimer == "Lookatdoor_01")
{
StartPlayerLookAt("castle_1",2.0f,5.0f,"");
AddTimer("Lookatdoor_02",1.5f,"LookAtDoor");
}

if(asTimer == "Lookatdoor_02")
{
StopPlayerLookAt();
}
}

// Run when entering map
void OnEnter()
{
PlayMusic("27_paper_daniel01.ogg", true, 1.0f, 0, 0, true);
}


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

}
What do you mean by "lookable object"???

Also i tried your script akasu but still no luck Sad
This is the way I'd do it myself:
Code:
////////////////////////////
// Run first time start[/color]ing map
void OnStart()
{
AddEntityCollideCallback("Player", "Scare1", "LookAtDoor", true, 0);
AddUseItemCallback("", "Key1", "Unlock1", "UsedKeyOnDoor1", true);
FadeOut(0);
FadeIn(20);
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220);
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true);
AddTimer("trig1", 11.0f, "beginStory");
}

void beginStory(string &in asTimer)
{
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33);
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

void UsedKeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Unlock1", false, true);
PlaySoundAtEntity("", "unlock_door", "Unlock1", 0, false);
RemoveItem("Key1");
PlayMusic("02_puzzle.ogg", false, 0.7, 0.1, 10, true);
RemoveItem("Key1");
GiveSanityBoost();
}

void LookAtDoor(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("castle_1",2.0f,5.0f,"");
AddTimer("Lookatdoor_02",1.5f,"LookAtDoor2");
}

void LookAtDoor2(string& asEntityName)
{
StopPlayerLookAt();
}


// Run when entering map
void OnEnter()
{
PlayMusic("27_paper_daniel01.ogg", true, 1.0f, 0, 0, true);
}


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

}
If that doesn't work, it is possible that you've got the names wrong. You should check those out.
(02-12-2011, 11:05 PM)Akasu Wrote: [ -> ]This is the way I'd do it myself:
Code:
////////////////////////////
// Run first time start[/color]ing map
void OnStart()
{
AddEntityCollideCallback("Player", "Scare1", "LookAtDoor", true, 0);
AddUseItemCallback("", "Key1", "Unlock1", "UsedKeyOnDoor1", true);
FadeOut(0);
FadeIn(20);
FadeImageTrailTo(2, 2);
FadeSepiaColorTo(100, 4);
SetPlayerActive(false);
FadePlayerRollTo(50, 220, 220);
FadeRadialBlurTo(0.15, 2);
SetPlayerCrouching(true);
AddTimer("trig1", 11.0f, "beginStory");
}

void beginStory(string &in asTimer)
{
ChangePlayerStateToNormal();
SetPlayerActive(true);
FadePlayerRollTo(0, 33, 33);
FadeRadialBlurTo(0.0, 1);
FadeSepiaColorTo(0, 4);
SetPlayerCrouching(false);
FadeImageTrailTo(0,1);
}

void UsedKeyOnDoor1(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Unlock1", false, true);
PlaySoundAtEntity("", "unlock_door", "Unlock1", 0, false);
RemoveItem("Key1");
PlayMusic("02_puzzle.ogg", false, 0.7, 0.1, 10, true);
RemoveItem("Key1");
GiveSanityBoost();
}

void LookAtDoor(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("castle_1",2.0f,5.0f,"");
AddTimer("Lookatdoor_02",1.5f,"LookAtDoor2");
}

void LookAtDoor2(string& asEntityName)
{
StopPlayerLookAt();
}


// Run when entering map
void OnEnter()
{
PlayMusic("27_paper_daniel01.ogg", true, 1.0f, 0, 0, true);
}


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

}
If that doesn't work, it is possible that you've got the names wrong. You should check those out.

Oh i see it was the names that were wrong Big Grin
Ty to everybody, but now i have a new problem.
It doesnt give me sanitiy boost when i open the door :/