forked from ThePix/quest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackLibrary.aslx
More file actions
234 lines (192 loc) · 6.34 KB
/
StackLibrary.aslx
File metadata and controls
234 lines (192 loc) · 6.34 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<library>
<!--
The stack container must have these attributes:
-->
<!--
This should be called each time the stack content changes to keep it up to date.
You can send either the stack itself of a member of the stack.
-->
<function name="SetStack" parameters="container"><![CDATA[
if (DoesInherit(container, "childstack_object")) {
container = container.stackparent
}
if (not HasString(container, "originalalias")) {
if (HasString(container, "listalias")) {
container.originalalias = container.listalias
}
else {
container.originalalias = container.alias
}
}
stacked_count = ListCount(GetDirectChildren(container))
if (stacked_count = 0) {
container.parent = Stack Containers
}
else if (stacked_count = 1) {
container.gender = "it"
container.article = "it"
if (container.parent = Stack Containers) {
container.parent = game.pov
}
}
else {
container.gender = "they"
container.article = "them"
}
container.listalias = container.originalalias + ": " + ToString(stacked_count)
]]></function>
<!--
Remove an item from the given stack. If there is more than one
there, the player will be asked to choose.
-->
<function name="Unstack" parameters="container"><![CDATA[
DoStackStuff(container, "_Unstack", null, "Drop which one?")
]]></function>
<!--
Use an item from the given stack. If there is more than one
there, the player will be asked to choose.
-->
<function name="UseInStack" parameters="container"><![CDATA[
DoStackStuff(container, "_UseInStack", null, "Use which one?")
]]></function>
<!--
Use an item from the given stack. If there is more than one
there, the player will be asked to choose.
-->
<function name="LookInStack" parameters="container"><![CDATA[
DoStackStuff(container, null, "look", "Look at which one?")
]]></function>
<!--
Use an item from the given stack. If there is more than one
there, the player will be asked to choose.
-->
<function name="ConsumeInStack" parameters="container"><![CDATA[
DoStackStuff(container, null, "consume", "Consume which one?")
]]></function>
<!--
Use an item from the given stack. If there is more than one
there, the player will be asked to choose.
-->
<function name="DoStackVerb" parameters="container, verb"><![CDATA[
DoStackStuff(container, null, verb, CapFirst(verb) + " which one?")
]]></function>
<!--
Do something with an item from the given stack. If there is more than one
there, the player will be asked to choose.
This will then call a script on the object, if script is not null, or
otherwise the given function.
s is the prompt.
-->
<function name="DoStackStuff" parameters="container, functionname, scriptname, s"><![CDATA[
if (ListCount(GetDirectChildren(container)) = 1) {
if (not scriptname = null) {
//msg("here")
//msg(ObjectListItem(GetDirectChildren(container), 0))
PrintOrRun(ObjectListItem(GetDirectChildren(container), 0), scriptname)
SetStack(container)
}
else {
game.tempobj = ObjectListItem(GetDirectChildren(container), 0)
f = Eval (functionname + "(game.tempobj)")
}
}
else {
dic = NewStringDictionary()
foreach (o, GetDirectChildren(container)) {
dictionary add (dic, o.name, o.alias)
}
game.functionname_tmp = functionname
game.scriptname_tmp = scriptname
ShowMenu (s, dic, true) {
if (result = null) {
msg ("You decide not to drop anything.")
}
else {
game.tempobj = GetObject(result)
if (not game.scriptname_tmp = null) {
PrintOrRun(game.tempobj, game.scriptname_tmp)
}
else {
game.tempobj = GetObject(result)
f = Eval (game.functionname_tmp + "(game.tempobj)")
}
}
}
}
]]></function>
<function name="_Unstack" parameters="object" type="boolean"><![CDATA[
container = object.stackparent
object.parent = game.pov.parent
SetStack(container)
msg("You drop " + GetDisplayName(object) + ".")
if (HasScript(object, "ondrop")) do(object, "ondrop")
return(true)
]]></function>
<function name="_UseInStack" parameters="object" type="boolean"><![CDATA[
dic = NewDictionary()
dictionary add (dic, "object", object)
do(use, "script", dic)
SetStack(object)
return(true)
]]></function>
<!--
-->
<function name="PrintOrRun" parameters="obj, att">
if (HasScript(obj, att)) {
do (obj, att)
}
if (HasString(obj, att)) {
msg (GetString(obj, att))
}
</function>
<type name="stack_container">
<parent type="object">game</parent>
<drop type="script">
Unstack (this)
</drop>
<use type="script">
UseInStack (this)
</use>
<consume type="script">
ConsumeInStack (this)
</consume>
<look type="script">
LookInStack (this)
</look>
</type>
<type name="childstack_object">
<isstackable />
<drop type="boolean">false</drop>
<takemsg>You take it.</takemsg>
<take type="script">
if (this.alias = null) {
this.alias = object.name
}
container = this.stackparent
this.parent = container
SetStack(container)
if (this.takemsg = null) {
msg(DynamicTemplate("TakeSuccessful", object))
}
else {
msg (this.takemsg)
}
</take>
</type>
<tab>
<parent>_ObjectEditor</parent>
<caption>Stackable</caption>
<mustnotinherit>editor_room; editor_player</mustnotinherit>
<control>
<controltype>dropdowntypes</controltype>
<types>*=Not stackable; stack_container=The stack itself; childstack_object=Member of a stack</types>
<caption>Stack</caption>
</control>
<control>
<controltype>objects</controltype>
<attribute>stackparent</attribute>
<mustinherit>childstack_object</mustinherit>
<caption>Stack container</caption>
</control>
</tab>
</library>