Frictional Games Forum (read-only)
[SCRIPT] Message Help [SOLVED] - 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] Message Help [SOLVED] (/thread-38984.html)



Message Help [SOLVED] - WarJenkins - 02-19-2016

Hello again, I guess. I'm trying to make a script where if you look at a object, a message appears, but it ain't working. I'm pretty noobish at scripting, and I know that everyone says that, but hey.

.hps code:

Code:
void OnStart()
{
    AddUseItemCallback("", "key1", "door01", "func", true);
    AddUseItemCallback("", "chip", "door01", "afunc", true);
    SetPlayerLampOil(0);
    SetMessage("Messages", "start", 4);
    AddEntityCollideCallback("Player", "act", "actfunc", true, 1);
}

void func(string &in asItem, string &in asEntity)
{
    PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
    RemoveItem(asItem);
    AddQuest("", "KeyBroke");
}

void afunc(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked(asEntity, false, true);
    PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
    RemoveItem(asItem);
    CompleteQuest("", "KeyBroke");
    PlaySoundAtEntity("", "unlock_door", asEntity, 0, false);
    PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
}

void actfunc (string &in asItem, string &in asEntity)

{
    SetMessage("Messages", "uh", 6);
}

.lang code:

Code:
<LANGUAGE>  
    <CATEGORY Name="CustomStoryMain">
        <Entry Name="Description">A small custom story.</Entry>
    </CATEGORY>    
    
    <CATEGORY Name="Inventory">
        <Entry Name="ItemName_key1">My Room Key</Entry>
        <Entry Name="ItemDesc_key1">Rusty as hell.</Entry>
        <Entry Name="ItemName_chip">a Nail</Entry>
        <Entry Name="ItemDesc_chip">A little bit too big for it's own good. Presumebly I can use this on the door.</Entry>
    </CATEGORY>

<CATEGORY Name="Journal">
    <Entry Name="Note_Note01_Name">What?</Entry>
    <Entry Name="Note_Note01_Text">What for sure.</Entry>
    <Entry Name="Quest_KeyBroke_Text">The key broke somehow, I need to look for some key-like item around my room.
    </Entry>
</CATEGORY>

  <CATEGORY Name="Messages">
<Entry Name ="start">What was that noise?!</Entry>
<Entry Name ="uh">Uh oh... That does not look good.</Entry>
</CATEGORY>
</LANGUAGE>

And again, any help is appreciated.


RE: Message Help - Spelos - 02-19-2016

If you want a message to appear when Player looks at something, you will need a PlayerLookAtCallback.

Frictional Games Wiki Wrote:void SetEntityPlayerLookAtCallback(string& asName, string& asCallback, bool abRemoveWhenLookedAt);

To use it, you will need:
  • Entity in the level editor
    Do remember the name of that entity! For example: MyDoor

How to use the callback:
  • Put it into the OnStart function and fill the parameters.
  • Use the void MyFunc(string &in asEntity, int alState) as your function to call.

What it should look like:
PHP Code:
void OnStart()
{
    
AddUseItemCallback("""key1""door01""func"true);
    
AddUseItemCallback("""chip""door01""afunc"true);
    
SetPlayerLampOil(0);
    
SetMessage("Messages""start"4);
    
AddEntityCollideCallback("Player""act""actfunc"true1);

    
//"MyDoor" is the name of the entity to look at, "LookMessage" is the function to call, false - if the message should remove itself after the first time Player looks at it.
    
SetEntityPlayerLookAtCallback("MyDoor""LookMessage"false);
}

void LookMessage(string &in asEntityint alState
{
    
SetMessage("MessageCategory""MessageEntry"0); //Fill in the category and Entry
}

// \/ --- The rest of your code here --- \/ // 



RE: Message Help - WarJenkins - 02-19-2016

You're my custom story savior, thank you!