-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.ws
67 lines (56 loc) · 1.74 KB
/
example.ws
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
/**
* a basic example that shows how to add a custom injector to a nearby
* noticeboard.
*/
exec function suadderrandinjector() {
var entities: array<CGameplayEntity>;
var board: W3NoticeBoard;
FindGameplayEntitiesInRange(
entities,
thePlayer,
10, // range,
1, // max results
, // tag: optional value
FLAG_ExcludePlayer,
, // optional value
'W3NoticeBoard'
);
if (entities.Size() < 1) {
theGame
.GetGuiManager()
.ShowNotification("Could not find any noticeboard nearby");
}
board = (W3NoticeBoard)entities[0];
if (board) {
board.addErrandInjector(new SU_ErrandInjectorExample in board);
theGame
.GetGuiManager()
.ShowNotification("added example injector");
}
else {
theGame
.GetGuiManager()
.ShowNotification("Could not find any noticeboard nearby (cast fail)");
}
}
class SU_ErrandInjectorExample extends SU_ErrandInjector {
public function run(board: W3NoticeBoard) {
SU_replaceFlawWithErrand(board, "hello world!");
}
public function accepted(board: W3NoticeBoard, errand_name: string) {
theGame
.GetGuiManager()
.ShowNotification("accepted errand with name = " + errand_name);
this.logErrandWithName(board, errand_name);
}
private function logErrandWithName(board: W3NoticeBoard, errand_name: string) {
var i: int;
for (i = 0; i < board.activeErrands.Size(); i += 1) {
if (board.activeErrands[i].errandStringKey == errand_name) {
LogChannel('SUTEST', "accepted errand with name = " + errand_name);
LogChannel('SUTEST', "accepted errand with title = " + GetLocStringByKey(errand_name));
LogChannel('SUTEST', "accepted errand with body = " + GetLocStringByKey(errand_name + "_text"));
}
}
}
}