-
Notifications
You must be signed in to change notification settings - Fork 0
/
Openable.as
executable file
·105 lines (84 loc) · 2.15 KB
/
Openable.as
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* an object with two states, that
transitions between them (or from
one to the other only) by the
handle action. The object keeps its
state even when leaving the room.
This is usually used for openable
doors.
frames:
0 : "closed" (default)
1 : "open"
*/
class Openable extends StaticThing {
var globalname : String;
var opentext : String;
var reacharea : String;
var openverb : String;
var closeverb : String;
/* one-way transition, optional text */
var cannotclose : Boolean;
var noclosetext : String;
public function onLoad () {
super.onLoad();
/* defaults */
if (openverb == undefined)
openverb = "open";
if (closeverb == undefined)
closeverb = "close";
if (description == undefined)
description = "It's a door.";
if (eyeballverb == undefined)
eyeballverb = "look at";
if (showname == undefined)
showname = "door";
if (defaulttool == undefined)
defaulttool = 2; /* hand */
if (isopen()) {
handleverb = closeverb;
this.gotoAndStop(2);
} else {
handleverb = openverb;
this.gotoAndStop(1);
}
}
public function isopen() {
return _root["memory"].getFlag(globalname);
}
/* stubs, for overriding */
public function open () {}
public function close () {}
public function dohandle () {
var m : MovieClip = _root[this.reacharea];
if(m == undefined || _root["player"].anyhit(m)) {
if (opentext == undefined) {
/* by default say nothing.. */
} else {
/* only when opening */
if (this._currentframe == 1) {
_root["player"].say(opentext);
}
}
if (this._currentframe == 1) {
_root["memory"].setFlag(this.globalname);
handleverb = closeverb;
this.gotoAndStop(2);
open ();
} else {
if (this.cannotclose == undefined ||
!this.cannotclose) {
_root["memory"].clearFlag(this.globalname);
handleverb = openverb;
this.gotoAndStop(1);
close ();
} else {
/* can't close! */
if (this.noclosetext != undefined) {
_root["player"].say(noclosetext);
}
}
}
} else {
_root["player"].say("I can't reach it from here.");
}
}
}