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 Callback Function Usage?
Verkehr Offline
Member

Posts: 60
Threads: 13
Joined: Oct 2016
Reputation: 1
#1
Callback Function Usage?

I don't understand how to use the Callback Func that you can set for an entity inside of the level editor. Exactly the "CallbackFunc".

How do I make it be "OnPickup"? I want it to show a message (SetMessage) for the player if he picks up a note, and I want to use this CallbackFunc, but I don't know how it works!
12-13-2017, 06:36 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Callback Function Usage?

Using the generic CallbackFunc is basically a single callback for multiple events. It's ran for every event that is listed, like Break, OnPickup, OnIgnite etc, but not all of these apply to all objects.

If you want only OnPickup, just check for it at the start of the function.

PHP Code: (Select All)
void OnStart()
{
    
SetEntityCallbackFunc("entity""MyFunc");
}

void MyFunc(string &in asEntitystring &in asType)
{
    if(
asType == "OnPickup")
    {
        
SetMessage("Messages""NoteMessage"0);
    }


Similarly you can check for other types of events.

(This post was last modified: 12-13-2017, 09:08 PM by Mudbill.)
12-13-2017, 09:07 PM
Find
Verkehr Offline
Member

Posts: 60
Threads: 13
Joined: Oct 2016
Reputation: 1
#3
RE: Callback Function Usage?

(12-13-2017, 09:07 PM)Mudbill Wrote: Using the generic CallbackFunc is basically a single callback for multiple events. It's ran for every event that is listed, like Break, OnPickup, OnIgnite etc, but not all of these apply to all objects.

If you want only OnPickup, just check for it at the start of the function.

PHP Code: (Select All)
void OnStart()
{
    
SetEntityCallbackFunc("entity""MyFunc");
}

void MyFunc(string &in asEntitystring &in asType)
{
    if(
asType == "OnPickup")
    {
        
SetMessage("Messages""NoteMessage"0);
    }


Similarly you can check for other types of events.

Ohhhh, so I have to use ' if(asType == "OnPickup") ' to make that happen! Do I have to use ' SetEntityCallbackFunc("entity", "MyFunc"); ' though, despite that it's already set as the function inside of the map editor?

Thanks eitherway. Smile
(This post was last modified: 12-14-2017, 07:23 PM by Verkehr.)
12-14-2017, 07:23 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: Callback Function Usage?

Nah, if you've set it in the level editor, you don't need that bit in OnStart. Both have the same effect.

12-14-2017, 11:14 PM
Find




Users browsing this thread: 1 Guest(s)