Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Message Help [SOLVED]
WarJenkins Offline
Junior Member

Posts: 4
Threads: 2
Joined: Feb 2016
Reputation: 0
#1
Message Help [SOLVED]

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:

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:

<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.
(This post was last modified: 02-19-2016, 03:52 PM by WarJenkins.)
02-19-2016, 01:13 PM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#2
RE: Message Help

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: (Select All)
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 --- \/ // 
(This post was last modified: 02-19-2016, 03:33 PM by Spelos.)
02-19-2016, 03:30 PM
Find
WarJenkins Offline
Junior Member

Posts: 4
Threads: 2
Joined: Feb 2016
Reputation: 0
#3
RE: Message Help

You're my custom story savior, thank you!
02-19-2016, 03:51 PM
Find




Users browsing this thread: 1 Guest(s)