Frictional Games Forum (read-only)
Script help with Callbacks - 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 help with Callbacks (/thread-9210.html)



Script help with Callbacks - convolution223 - 07-18-2011

I'm really sorry for asking this, but I'm not a programmer. I don't understand how to use callbacks. There's 4 different types of callbacks for certain entities and the text fields in the level editor are making it more confusing than if i just had to type a function in the .hps. How do I use these? Any old example would do, I think. Unless they're all created in totally different ways.


RE: Script help with Callbacks - Tanshaydar - 07-18-2011

Look at Callback -> Calls the callback when entity is being looked by Player.
Interact Callback -> Calls the callback when entity is being interacted by Player.
Collide Callback -> Calls the callback when two different entities being collided (and when a Player enters an area, because both area and players are entities)
Use Item Callback -> Calls the callback when an item used on an entity.


RE: Script help with Callbacks - convolution223 - 07-18-2011

(07-18-2011, 05:45 AM)Tanshaydar Wrote: Look at Callback -> Calls the callback when entity is being looked by Player.
Interact Callback -> Calls the callback when entity is being interacted by Player.
Collide Callback -> Calls the callback when two different entities being collided (and when a Player enters an area, because both area and players are entities)
Use Item Callback -> Calls the callback when an item used on an entity.

Thanks but my problem is more on how do I use the level editor in conjunction with the .hps file to use these. Like, what do I type into those areas on the entity in the level editor? The name of the function, another name for the item, or something else entirely?


RE: Script help with Callbacks - ThePaSch - 07-18-2011

(07-18-2011, 06:44 AM)convolution223 Wrote: Thanks but my problem is more on how do I use the level editor in conjunction with the .hps file to use these. Like, what do I type into those areas on the entity in the level editor? The name of the function, another name for the item, or something else entirely?

You type the callback's name (=function) into the corresponding field; Tanshaydar explained them quite well.
If you hover over the fields, they show you the syntax you're going to have to use for the callback.

For example, you want the "interactedWithDoor"-method to be executed when a player interacts with a door. To do that, you go to the door's entity tab, look for the Interact Callback field and type "interactedWithDoor" (without the quotes) into it.
When you hover over the field, it shows you the syntax to be used. In this case, it's void MyFunc(string in entity).

The code would then be the following:
PHP Code:
void interactedWithDoor(string &in entity) {
//do stuff




RE: Script help with Callbacks - convolution223 - 07-18-2011

(07-18-2011, 06:54 AM)ThePaSch Wrote:
(07-18-2011, 06:44 AM)convolution223 Wrote: Thanks but my problem is more on how do I use the level editor in conjunction with the .hps file to use these. Like, what do I type into those areas on the entity in the level editor? The name of the function, another name for the item, or something else entirely?

You type the callback's name (=function) into the corresponding field; Tanshaydar explained them quite well.
If you hover over the fields, they show you the syntax you're going to have to use for the callback.

For example, you want the "interactedWithDoor"-method to be executed when a player interacts with a door. To do that, you go to the door's entity tab, look for the Interact Callback field and type "interactedWithDoor" (without the quotes) into it.
When you hover over the field, it shows you the syntax to be used. In this case, it's void MyFunc(string in entity).

The code would then be the following:
PHP Code:
void interactedWithDoor(string &in entity) {
//do stuff


Thanks again!!! You helped me twice tonight! I am speechlessly grateful Big Grin