Frictional Games Forum (read-only)
Display message only when looking at an entity - 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: Display message only when looking at an entity (/thread-18499.html)

Pages: 1 2


Display message only when looking at an entity - Akos115 - 09-25-2012

What I want, is to make a message appear on the screen when the player looks at an entity. But when i use my script, the message is displayed two times: when the player looks at it, and when looks away from it after looking at it.Here is my script:

void OnStart ()
{
SetEntityPlayerLookAtCallback("chair", "price_chair", false);

}


void price_chair(string &in asEntity, int alState)
{
SetMessage("price", "chair", 0);
}

I tried to change "int alState" into "int 1", but then the game crashes. Anyone got an idea? C:


RE: Display message only when looking at an entity - Robby - 09-25-2012

Try changing the false in the Callback to true. That may help.


RE: Display message only when looking at an entity - Akos115 - 09-25-2012

But that would delete the callback after it gets used, and I want it to use ulimited times.


RE: Display message only when looking at an entity - Robby - 09-25-2012

Well, that may be why it does that. I'm not certain of that, though.


RE: Display message only when looking at an entity - Statyk - 09-25-2012

You could try setting up a timer that disables the callback for say, 10 seconds after looking at it, then sets active again.


RE: Display message only when looking at an entity - Akos115 - 09-25-2012

thats a good idea Big Grin thanks a lot


RE: Display message only when looking at an entity - FlawlessHappiness - 09-25-2012

Or just do:

if(alState == 1)
{
SetMessage
}

if(alState == -1)
{

}


RE: Display message only when looking at an entity - Akos115 - 09-25-2012

even better Smile
thanks again


RE: Display message only when looking at an entity - Robby - 09-25-2012

Tip: If you get an error in your script (the game crashes), closely read the error, looking for numbers like (7, 2)

Then, go down to the 7th row, and look in there. That's where the problem is (I used an example here).


RE: Display message only when looking at an entity - Akos115 - 09-25-2012

I tried it but it didnt work:


void price_lantern(string &in asEntity, int alState)
{
if(alState == 1)
{
SetMessage("price", "lantern", 1);
}
if(alState == -1)
{

}
}