File: entityevent.md

package info (click to toggle)
surgescript 0.5.4.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,876 kB
  • sloc: ansic: 13,674; makefile: 16
file content (78 lines) | stat: -rw-r--r-- 1,390 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
EntityEvent
===========

An EntityEvent is an [event](/engine/event) that calls a function of an [entity](/engine/entity) when triggered.

Factory
-------

#### Events.EntityEvent

`Events.EntityEvent`

Spawns an EntityEvent.

*Arguments*

* `entityID`: string. The ID of an entity.

*Returns*

A new EntityEvent linked to the specified entity.

*Example*

```
// This is a level setup object. Make sure to link it in your .lev file!
using SurgeEngine.Level;
using SurgeEngine.Events.EntityEvent;

object "My Level Setup"
{
    fun constructor()
    {
        Level.setup({
            "Event Trigger 1": {
                "onTrigger": EntityEvent("aeb587eed1057a5e").willCall("open")
            }
        });
    }
}
```

Functions
---------

#### willCall

`willCall(functionName)`

Specifies the name of the function that will be called.

*Arguments*

`functionName`: string. The name of the function that will be called when the event is triggered.

*Returns*

The EntityEvent object.

#### withArgument

`withArgument(data)`

Adds an argument to the EntityEvent. Arguments added to the EntityEvent will be passed to the entity when the event is triggered - in the order they have been added. To add multiple arguments, call this function multiple times.

*Arguments*

`data`: any. The argument to be added.

*Returns*

The EntityEvent object.

#### call

`call()`

Triggers the event.