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
PlayerLookAtCallback not working
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#1
PlayerLookAtCallback not working

I want to trigger a function when the player looks at a corpse, but the script doesn't want to compile and always puts out the 'Expected data type' error..

void LookAtCorpses(string &in entity, 1)
{
    PlaySoundAtEntity("", "04_break02.snt", "Player", 3.0f, true);
}

The PlaySoundAt.. is just a filler to see if the Callback worked, but it doesn't.

The func name is in the PlayerLookAtCallback field in the editor's entity tab, the callback syntax is correct afaik. Now what is wrong?


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
10-16-2010, 04:14 PM
Find
Pandemoneus Offline
Senior Member

Posts: 328
Threads: 2
Joined: Sep 2010
Reputation: 0
#2
RE: PlayerLookAtCallback not working

You don't change any parameters in the function. It should be:

void LookAtCorpses(string &in entity, int alState)
{
    if(alState == 1) PlaySoundAtEntity("", "04_break02.snt", "Player", 3.0f, true);
}

10-16-2010, 05:16 PM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#3
RE: PlayerLookAtCallback not working

Does that count for every callback function? Never touch anything you see in the brackets ()?

Thanks, it works like a charm now, I'm often surprised how you're supposed to figure that out, though :|


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
10-16-2010, 05:21 PM
Find
Entih Offline
Junior Member

Posts: 47
Threads: 4
Joined: Sep 2010
Reputation: 0
#4
RE: PlayerLookAtCallback not working

Haha, I never knew there were parameters for the look-at callback function, I have just been using empty parameter lists, like "void CellarLookView()". I did notice that it would behave weirdly like that, but it worked.

But yes, when you are defining a function, it is always strictly data types and variables, the game fills them in at runtime. You never fill in values then.
10-16-2010, 06:04 PM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#5
RE: PlayerLookAtCallback not working

So putting a 1 there would mean to force the game to believe the player is always looking at the corpse, but the look-at-variable (???) tells the game the player isn't, which leads to the compiler preventing all this hassle and giving me an error.

Lol wut?


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
10-16-2010, 06:31 PM
Find
Entih Offline
Junior Member

Posts: 47
Threads: 4
Joined: Sep 2010
Reputation: 0
#6
RE: PlayerLookAtCallback not working

Nope, putting something in there will make the game fail to understand it completely. You see, to the game 'LookAtCorpses' is the same as a function like 'RemoveItem' or 'SetSwingDoorClosed'.

These functions are defined as 'void RemoveItem(string& asName)', or 'void SetSwingDoorClosed(string& asName, bool abClosed, bool abEffects)', just as your function is 'void LookAtCorpses(string &in entity, int alState)'.

What happens is these variables in the parameter list are filled in by the game itself when it comes to the time the game runs, and putting a constant like '1' in there instead of a variable name will cause it to say "wait, that's not right, I was expecting a variable name, not a value".

For example, when you actually use the function 'RemoveItem' is when you fill in a value. By typing something like 'RemoveItem("key");' you're telling it "I'm running RemoveItem. asName will become the string 'key'."

When the game runs LookAtCorpses because the view went onto the corpses, it automatically says "Alright, the player fulfilled the callback by looking at entity 'corpse'. Since the view went onto 'corpse' and the player is looking at it, alState is 1."
10-16-2010, 08:25 PM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#7
RE: PlayerLookAtCallback not working

Thanks for this thorough explanation!


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
10-16-2010, 08:51 PM
Find




Users browsing this thread: 1 Guest(s)