File: delayedevent.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 (74 lines) | stat: -rw-r--r-- 1,535 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
DelayedEvent
============

A DelayedEvent is an [event](/engine/event) that, when triggered, triggers another event after a specified time has passed.

Factory
-------

#### Events.DelayedEvent

`Events.DelayedEvent(event)`

Spawns a DelayedEvent.

*Arguments*

* `event`: [event](/engine/event) object. The event to be delayed.

*Returns*

A new DelayedEvent that, when triggered, will trigger the specified event after a delay.

*Example*

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

object "My Level Setup"
{
    fun constructor()
    {
        Level.setup({
            "Event Trigger 1": {
                "onTrigger": EventList([
                    FunctionEvent("Print").withArgument("Hello!"),
                    DelayedEvent(
                        FunctionEvent("Print").withArgument("This is...")
                    ).willWait(2.0), // wait 2 seconds before triggering this
                    DelayedEvent(
                        FunctionEvent("Print").withArgument("SurgeScript!")
                    ).willWait(4.0) // wait 4 seconds before triggering this
                ])
            }
        });
    }
}
```

Functions
---------

#### willWait

`willWait(seconds)`

Set the delay to trigger the event.

*Arguments*

`seconds`: number. The delay, in seconds.

*Returns*

The DelayedEvent object.

#### call

`call()`

Triggers the event.