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


Thread Rating:
  • 5 Vote(s) - 3.8 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting, need urgent help!
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
RE: Scripting, need urgent help!

Kyle Wrote:There is no SetEntityCallbackFunc.
There is:
Spoiler below!
void SetEntityCallbackFunc(string& asName, string& asCallback);

Calls a function when the player interacts with a certain entity.
Callback syntax: void MyFunc(string &in asEntity, string &in type)
Type depends on entity type and includes: “OnPickup”, “Break”, “OnIgnite”, etc


void OnEnter ()
{
AddUseItemCallback("", "keyone", "door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("notethree", "Func");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door1", 0, false);
RemoveItem("keyone");
}
void Func(string &in asEntity, string &in type)
{
if(type == "OnPickup")
{
PlaySoundAtEntity("", "15_body_impact.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_pant5.snt", "Player", 0, false);
StartPlayerLookAt("Player", 3.0f, 3.0f, "");
AddTimer("atticscare", 1, "Func2");
}
}
void OnLeave ()
{
}

This is your fixed code.

A function works like this:
First you need a callback, which 'calls' the function: (for example)
SetEntityCallbackFunc("notethree", "Func");
-> This will call the function "Func".

A function is a part of the code, which only runs through, if it's called.
It starts with void FuncNameHere(ParametersHere){}
In the brackets are the actions, which should be triggered, when the
callback happens

The Well: Descent - Take a look at it!
07-27-2011, 11:15 AM
Find
JetlinerX Offline
Senior Member

Posts: 599
Threads: 49
Joined: Jun 2011
Reputation: 19
RE: Scripting, need urgent help!

OMG!!! I GET IT NOW!!! I totally see what everyone was talking about! That code also works to play the sound! YESSSSSSS!!!

One last thing, this is probably in the extra_eng most likely, but how do I make some sort of subtitle on the bottom after the sound, for instance:

"That sound came from the attic right above me, whats going on?"

Also, my second key is not working with this code and I have tried everything I can...

void OnEnter ()
{
AddUseItemCallback("", "keyone", "door1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "key_attic", "atticdoor", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_attic", "Func");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door1", 0, false);
RemoveItem("keyone");
}
void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("atticdoor", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "atticdoor", 0, false);
RemoveItem("key_attic");
}
void Func(string &in asEntity, string &in type)
{
if(type == "OnPickup")
{
PlaySoundAtEntity("", "15_body_impact.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_pant5.snt", "Player", 0, false);
StartPlayerLookAt("Player", 3.0f, 3.0f, "");
AddTimer("atticscare", 1, "OnPickup");
}
}
void OnLeave ()
{
}

Lead Developer of "The Attic"
~Slade Mitchell

Chapter 3 (REL)

(This post was last modified: 07-27-2011, 05:11 PM by JetlinerX.)
07-27-2011, 04:30 PM
Website Find
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
RE: Scripting, need urgent help!

Check your syntax, you're missing a closing bracket for "UsedKeyOnDoor".

Also, refer to http://wiki.frictionalgames.com/hpl2/amn..._functions

void SetMessage(string& asTextCategory, string& asTextEntry, float afTime);
Displays a message on the screen.

asTextCategory - the category in the .lang file
asTextEntry - the entry in the .lang file
afTime - determines how long the message is displayed. If time is < =0 then the life time is calculated based on string length.

07-27-2011, 06:24 PM
Find
JetlinerX Offline
Senior Member

Posts: 599
Threads: 49
Joined: Jun 2011
Reputation: 19
RE: Scripting, need urgent help!

On the first "UsedKeyOnDoor" or the second? I cant see what one you mean as they both look the same.

Also, where does that SetMessage go so that it knows when to come up?

Also, I totally forgot about the Scripts Func page! Thanks for reminding me!

Lead Developer of "The Attic"
~Slade Mitchell

Chapter 3 (REL)

(This post was last modified: 07-27-2011, 06:40 PM by JetlinerX.)
07-27-2011, 06:33 PM
Website Find
xiphirx Offline
Senior Member

Posts: 662
Threads: 16
Joined: Nov 2010
Reputation: 5
RE: Scripting, need urgent help!

Ah, I didn't notice the scrollbar for your script Tongue

void OnEnter ()
{
    AddUseItemCallback("", "keyone", "door1", "UsedKeyOnDoor", true);
    AddUseItemCallback("", "key_attic", "atticdoor", "UsedKeyOnDoor", true);
    SetEntityCallbackFunc("key_attic", "Func");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("door1", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "door1", 0, false);
    RemoveItem("keyone");
}
void UsedKeyOnDoor2(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("atticdoor", false, true);
    PlaySoundAtEntity("", "unlock_door.snt", "atticdoor", 0, false);
    RemoveItem("key_attic");
}
void Func(string &in asEntity, string &in type)
{
    if(type == "OnPickup")
    {
        PlaySoundAtEntity("", "15_body_impact.snt", "Player", 0, false);
        PlaySoundAtEntity("", "react_pant5.snt", "Player", 0, false);
        StartPlayerLookAt("Player", 3.0f, 3.0f, "");
        AddTimer("atticscare", 1, "OnPickup");
    }
}
void OnLeave ()
{
}

Now pay attention to this part
    AddUseItemCallback("", "keyone", "door1", "UsedKeyOnDoor", true);
    AddUseItemCallback("", "key_attic", "atticdoor", "UsedKeyOnDoor", true);

You're calling the same key function for both doors here, you just forgot the "2" for the second door

    AddUseItemCallback("", "keyone", "door1", "UsedKeyOnDoor", true);
    AddUseItemCallback("", "key_attic", "atticdoor", "UsedKeyOnDoor2", true);


07-27-2011, 06:41 PM
Find
JetlinerX Offline
Senior Member

Posts: 599
Threads: 49
Joined: Jun 2011
Reputation: 19
RE: Scripting, need urgent help!

OH CRAP! Nice call! Dang it, this stuff is so tedious!
Hm, It would appear the door remains locked after using the key... ideas?

Lead Developer of "The Attic"
~Slade Mitchell

Chapter 3 (REL)

(This post was last modified: 07-27-2011, 06:56 PM by JetlinerX.)
07-27-2011, 06:46 PM
Website Find
JenniferOrange Offline
Senior Member

Posts: 424
Threads: 43
Joined: Jun 2011
Reputation: 33
RE: Scripting, need urgent help!

To set a message after the sound:

{
PlaySoundAtEntity("", "15_body_impact.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_pant5.snt", "Player", 0, false);
StartPlayerLookAt("Player", 3.0f, 3.0f, "");
AddTimer("atticscare", 1, "OnPickup");
SetMessage("Messages", "scare", 0);
}

thats for your .hps .

This is for your .lang file=
Add this Category, if you don't already have it:
<CATEGORY Name="Messages">
      <Entry Name="scare">yourtexthere</Entry>
</CATEGORY>

And there you go! Smile


Ba-da bing, ba-da boom.
07-27-2011, 07:54 PM
Find
JetlinerX Offline
Senior Member

Posts: 599
Threads: 49
Joined: Jun 2011
Reputation: 19
RE: Scripting, need urgent help!

So the script is just reading it in order, so when the sounds play, it will read the message next? Interesting as 99% of the other parts of the code dont do that, which is why its so confusing! XD

Thanks again "Jennifer" you always come through Wink

Ill let you all know what the results are.

Lead Developer of "The Attic"
~Slade Mitchell

Chapter 3 (REL)

07-27-2011, 08:57 PM
Website Find
JetlinerX Offline
Senior Member

Posts: 599
Threads: 49
Joined: Jun 2011
Reputation: 19
RE: Scripting, need urgent help!

The message did not pop up after picking up the key :/

Lead Developer of "The Attic"
~Slade Mitchell

Chapter 3 (REL)

07-27-2011, 11:15 PM
Website Find
JetlinerX Offline
Senior Member

Posts: 599
Threads: 49
Joined: Jun 2011
Reputation: 19
RE: Scripting, need urgent help!

Got it working ^^^^

Lead Developer of "The Attic"
~Slade Mitchell

Chapter 3 (REL)

07-28-2011, 04:37 AM
Website Find




Users browsing this thread: 1 Guest(s)