Frictional Games Forum (read-only)
Help with looking at area - 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: Help with looking at area (/thread-21620.html)



Help with looking at area - Wank - 05-26-2013

When the player looks at a certain script area I want it to say something. I assume the script you use has to do with "PlayerLookAtCallback" The area is called "Look".


RE: Help with looking at area - PutraenusAlivius - 05-26-2013

This is the "voluntary" code. This means that the Player isn't being forced to look at this.
Code:
void OnStart()
{
SetEntityPlayerLookAtCallback("Look", "MessageAppear", true); //Change true to false if you want the message to appear over and over again.
}

void MessageAppear(string &in asEntity, int alState)
{
SetMessage("MessageCategory", "MessageEntry", 0); //Change 0 to how long you want the message to appear. 0 means it will count how many strings it have and calculate the time.
}



RE: Help with looking at area - Wank - 05-26-2013

(05-26-2013, 01:53 AM)JustAnotherPlayer Wrote: This is the "voluntary" code. This means that the Player isn't being forced to look at this.
Code:
void OnStart()
{
SetEntityPlayerLookAtCallback("Look", "MessageAppear", true); //Change true to false if you want the message to appear over and over again.
}

void MessageAppear(string &in asEntity, int alState)
{
SetMessage("MessageCategory", "MessageEntry", 0); //Change 0 to how long you want the message to appear. 0 means it will count how many strings it have and calculate the time.
}

What do I do for "Message Category" and "Message Entry"? This is a script area so...


RE: Help with looking at area - PutraenusAlivius - 05-26-2013

(05-26-2013, 01:58 AM)Wank Wrote:
(05-26-2013, 01:53 AM)JustAnotherPlayer Wrote: This is the "voluntary" code. This means that the Player isn't being forced to look at this.
Code:
void OnStart()
{
SetEntityPlayerLookAtCallback("Look", "MessageAppear", true); //Change true to false if you want the message to appear over and over again.
}

void MessageAppear(string &in asEntity, int alState)
{
SetMessage("MessageCategory", "MessageEntry", 0); //Change 0 to how long you want the message to appear. 0 means it will count how many strings it have and calculate the time.
}

What do I do for "Message Category" and "Message Entry"? This is a script area so...

You want a text to appear when the Player is looking at the area, right? The Message Category is the category of the message you want and Message Entry is the entry of the message in the same category earlier.


RE: Help with looking at area - Wank - 05-26-2013

(05-26-2013, 02:06 AM)JustAnotherPlayer Wrote:
(05-26-2013, 01:58 AM)Wank Wrote:
(05-26-2013, 01:53 AM)JustAnotherPlayer Wrote: This is the "voluntary" code. This means that the Player isn't being forced to look at this.
Code:
void OnStart()
{
SetEntityPlayerLookAtCallback("Look", "MessageAppear", true); //Change true to false if you want the message to appear over and over again.
}

void MessageAppear(string &in asEntity, int alState)
{
SetMessage("MessageCategory", "MessageEntry", 0); //Change 0 to how long you want the message to appear. 0 means it will count how many strings it have and calculate the time.
}

What do I do for "Message Category" and "Message Entry"? This is a script area so...

You want a text to appear when the Player is looking at the area, right? The Message Category is the category of the message you want and Message Entry is the entry of the message in the same category earlier.

I still don't fully understand. I have 11 areas likes this. Here is my code- (Oh and sorry for not understanding Sad ) So basiclly I want them to say what they are named so "A, B, C" blah blah blah.


void OnStart ()
{
SetEntityPlayerLookAtCallback("LookA", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookB", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookC", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookD", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookE", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookF", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookG", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookH", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookI-J", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookK", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookM", "MessageAppear", false);
}
void MessageAppear(string &in asEntity, int alState)
{
SetMessage("Message", "MessageEntry", 0); //Change 0 to how long you want the message to appear. 0 means it will count how many strings it have and calculate the time.
}

(05-26-2013, 02:08 AM)Wank Wrote:
(05-26-2013, 02:06 AM)JustAnotherPlayer Wrote:
(05-26-2013, 01:58 AM)Wank Wrote:
(05-26-2013, 01:53 AM)JustAnotherPlayer Wrote: This is the "voluntary" code. This means that the Player isn't being forced to look at this.
Code:
void OnStart()
{
SetEntityPlayerLookAtCallback("Look", "MessageAppear", true); //Change true to false if you want the message to appear over and over again.
}

void MessageAppear(string &in asEntity, int alState)
{
SetMessage("MessageCategory", "MessageEntry", 0); //Change 0 to how long you want the message to appear. 0 means it will count how many strings it have and calculate the time.
}

What do I do for "Message Category" and "Message Entry"? This is a script area so...

You want a text to appear when the Player is looking at the area, right? The Message Category is the category of the message you want and Message Entry is the entry of the message in the same category earlier.

I still don't fully understand. I have 11 areas likes this. Here is my code- (Oh and sorry for not understanding Sad ) So basiclly I want them to say what they are named so "A, B, C" blah blah blah.


void OnStart ()
{
SetEntityPlayerLookAtCallback("LookA", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookB", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookC", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookD", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookE", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookF", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookG", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookH", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookI-J", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookK", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookM", "MessageAppear", false);
}
void MessageAppear(string &in asEntity, int alState)
{
SetMessage("Message", "MessageEntry", 0); //Change 0 to how long you want the message to appear. 0 means it will count how many strings it have and calculate the time.
}

OK, I did some extra english stuff also. Still doesn't work..
Extra english-

<LANGUAGE>
<CATEGORY Name="CustomStoryMain">
<Entry Name="Description">You find yourself in the mansion of a deranged artist and musician. Could he be hiding something in this hidious house?</Entry>
</CATEGORY>

<CATEGORY Name="Journal">
<Entry Name="Note_letterone_Name">A quick note to self</Entry>
<Entry Name="Note_letterone_Text">So I don't forget- The key to the study is hidden behind the painting in my piano room!</Entry>
<Entry Name="Note_noteenvelope_Name">To Costa De Luca</Entry>
<Entry Name="Note_noteenvelope_Text">You are invited to show your work at the Bergam Art Museum! Bring any artwork pieces as you wish, and we will see you there! (1834, October 16th)</Entry>
<Entry Name="Note_diarypaperone_Name">Journal entry page one</Entry>
<Entry Name="Note_diarypaperone_Text">1834, October 16th. Now that I have been invited to Bergam, I can bring my master piece! It is almost prepared, I just need a few more parts.</Entry>
<Entry Name="Note_diarypapertwo_Name">Journal entry page two</Entry>
<Entry Name="Note_diarypapertwo_Text">1834, October 17th. The showcase is in two weeks, so I need to prepare more quickly. I am just missing one more thing, which is hard to get.[br]Heading down to the library now.</Entry>
<Entry Name="Note_notelibrary_Name">A Riddle in Rhyme</Entry>
<Entry Name="Note_notelibrary_Text">The first one is at K, and don't be too slow.[br]
The next one is at M, but you arleady know.[br]
The last one you need is in B, as you can see. [br]
Now you know my secret, so come and find me.[br]</Entry>
</CATEGORY>

<CATEGORY Name="MessageAppear">
<Entry Name="MessageEntry_LookA">A</Entry>
<Entry Name="MessageEntry_LookB">
<Entry Name="MessageEntry_LookC">
<Entry Name="MessageEntry_LookD">
<Entry Name="MessageEntry_LookE">
<Entry Name="MessageEntry_LookF">
<Entry Name="MessageEntry_LookG">
<Entry Name="MessageEntry_LookH">
<Entry Name="MessageEntry_LookI-J">
<Entry Name="MessageEntry_LookK">
<Entry Name="MessageEntry_LookM">
</LANGUAGE>


Script-

void OnStart ()
{
SetEntityPlayerLookAtCallback("LookA", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookB", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookC", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookD", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookE", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookF", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookG", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookH", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookI-J", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookK", "MessageAppear", false);
SetEntityPlayerLookAtCallback("LookM", "MessageAppear", false);
}
void MessageAppear(string &in asEntity, int alState)
{
SetMessage("MessageAppear", "MessageEntry", 5);
}


RE: Help with looking at area - PutraenusAlivius - 05-26-2013

For the .lang file, I'm gonna wait for someone else to give an explanation. That doesn't mean that I don't know it, but I don't know how to explain it. Btw, they all have the same function.


RE: Help with looking at area - Romulator - 05-26-2013

This is a very long post. So I will place it into spoilers to save room.

Fixing your .lang
Spoiler below!

Well, first thing's first, we need to fix your extra_english.lang file. Make some placeholder text and put a </CATEGORY> at the end.

Code:
<CATEGORY Name="MessageAppear">
<Entry Name="MessageEntry_LookA">A</Entry>
<Entry Name="MessageEntry_LookB">B</Entry>
<Entry Name="MessageEntry_LookC">C</Entry>
<Entry Name="MessageEntry_LookD">D</Entry>
<Entry Name="MessageEntry_LookE">E</Entry>
<Entry Name="MessageEntry_LookF">F</Entry>
<Entry Name="MessageEntry_LookG">G</Entry>
<Entry Name="MessageEntry_LookH">H</Entry>
<Entry Name="MessageEntry_LookI-J">I-J</Entry>
<Entry Name="MessageEntry_LookK">K</Entry>
<Entry Name="MessageEntry_LookM">M</Entry>
</CATEGORY>



SetEntityPlayerLookAtCallback
Spoiler below!

This is how the SetEntityPlayerLookAtCallback works:

PHP Code:
SetEntityPlayerLookAtCallback(stringasNamestringasCallbackbool abRemoveWhenLookedAt);

asName internal name
asCallback 
- function to call
abRemoveWhenLookedAt 
determines whether the callback should be removed when the player looked at the entity 

Change the following.
Code:
asName         What the player is looking at in order to show the text.
asCallback     The name of the script (I'll come back to that).
abRemove...  Either true or false. False means that no matter how many times you look, the message appears.

You also need to remove the string& and bool. Place any strings in quotation marks ("example"). And asName should be the name of what the player is looking at in the Level Editor.

So the example I will use is this:
PHP Code:
SetEntityPlayerLookAtCallback("ScriptArea_A""ShowMessageA"true); 

Which would go in the OnStart() function in script.

PHP Code:
OnStart()
{
SetEntityPlayerLookAtCallback("ScriptArea_A""ShowMessageA"true);



Making the message appear
Spoiler below!

The message is read with the SetMessage() function, which works like this.

Code:
SetMessage(string& asTextCategory, string& asTextEntry, float afTime);

asTextCategory    The category name in the extra_english.lang to read from
asTextEntry         The entry from the category above to display on screen
afTime                 Time in seconds to display.

You have your code correctly done, but I am changing the function to ShowMessageA for the time being:
PHP Code:
void ShowMessageA(string &in asEntityint alState)
 {
 
SetMessage("MessageAppear""MessageEntry_LookA"0.0f);
 } 

So in your extra_english.lang file, you need your messages. In your .lang file, you already have them declared in a category named MessageAppear:
Code:
<CATEGORY Name="MessageAppear">
And your messages organised as MessageEntry_Look(x) where x is a letter.

So the correct way to do this is to fix your SetMessage() to show these.
PHP Code:
SetMessage("MessageAppear""MessageEntry_LookA"0.0f); 

Then place it into your script.
PHP Code:
void ShowMessageA(string &in asEntityint alState)
 {
 
SetMessage("MessageAppear""MessageEntry_LookA"0.0f);
 } 

So your script should look like this in order just to get the first to work.

PHP Code:
OnStart()
{
SetEntityPlayerLookAtCallback("ScriptArea_A""ShowMessageA"true);
}

void ShowMessageA(string &in asEntityint alState)
 {
 
SetMessage("MessageAppear""MessageEntry_LookA"0.0f);
 } 


Repeat for the rest
Spoiler below!

Now it simply comes down to messing around with the code further to change what happens when you look at the other ones.

Where you see ..., you need to fill that in with your other lines of code. I cannot do it because I do not have that much patience and my text box is starting to lag on me.

PHP Code:
OnStart()
{
SetEntityPlayerLookAtCallback("ScriptArea_A""ShowMessageA"true);
SetEntityPlayerLookAtCallback("ScriptArea_B""ShowMessageB"true);
SetEntityPlayerLookAtCallback("ScriptArea_C""ShowMessageC"true);
SetEntityPlayerLookAtCallback("ScriptArea_D""ShowMessageD"true);
...
SetEntityPlayerLookAtCallback("ScriptArea_M""ShowMessageM"true);
}

void ShowMessageA(string &in asEntityint alState)
 {
 
SetMessage("MessageAppear""MessageEntry_LookA"0.0f);
 }

void ShowMessageB(string &in asEntityint alState)
 {
 
SetMessage("MessageAppear""MessageEntry_LookB"0.0f);
 }

void ShowMessageC(string &in asEntityint alState)
 {
 
SetMessage("MessageAppear""MessageEntry_LookC"0.0f);
 }
...
void ShowMessageM(string &in asEntityint alState)
 {
 
SetMessage("MessageAppear""MessageEntry_LookM"0.0f);
 }