1
!links.h library extension file
3
!This library provides some classes and the basic interfacing routines
4
!and verbs for Spider and Web style linkable objects. If you have no idea
5
!what I'm talking about, please go play Andrew Plotkin's excellent game,
6
!"Spider and Web". Also, a brief summary can be found in the piece of
7
!paper in links.inf, the sample game.
8
!Note that this code was not, repeat not, used in Spider and Web. In fact,
9
!S&W was what inspired me to write this library!
10
!This library and the sample game may be distributed freely. Having said
11
!that, if you use any of this code in a game, I'd appreciate at least a
12
!"Thank you" in your game.
14
!This code is very poorly formatted E.G. no indentation. Also, it may
15
!be written sloppily, but appears not to have much in the way of bugs.
16
!If you do find any bugs, please send me a letter at jaybird@coldmail.com.
17
!Classes in this library are:
18
!actuator, used for actuators E.G. buttons, switches, timers, etc, which
19
!are used to activate or trigger devices.
20
!device is for devices, E.G. beepers, lights, blenders, etc.
21
!switch is what it sounds like, an actuator that is a switch, with proper
22
!entries for switchon and switchoff to call the turnon and turnoff routines.
23
!remote is used for a device which is meant to remotely control an actuator.
24
!This is used for such things as the voice and key transmitters in Spider
25
!and Web, and the remote control in my links.inf sample game.
26
!Attributes you need to put on your linkable objects are:
27
!pluslink indicates that this object has a plus link. This is usually, but
28
!not always, used for actuators, at least it always was in Spider and Web.
29
!minuslink means this object has a minus link, which is usually, but not
30
!always, used for devices, although it always was in Spider and Web.
31
!Note that you can't link two objects with the same type of link together.
32
!Also note that once you've chosen what types of links to use for actuators
33
!and devices, it's a good idea to stick to those types so as not to confuse
35
!Routines and properties you should provide and know about:
36
!turnon is a string or routine which gets executed or run when a device is
37
!turned on via an actuator. It can do anything you want, even kill the
38
!player, win the game, or anything else that can normally be done.
39
!turnoff is the opposite of turnon in that it is what is run/executed when
40
!a device is turned off.
41
!brief is what happens when a device is activated briefly, such as the push
42
!of a button. If it's a device which does the same thing either way, such
43
!as a bomb, you can just have the brief call self.turnon to get the same
45
!baseunit is what tells a remote control what to control. Although it
46
!really doesn't get used in this code, your code may use it if it wishes.
47
!Also note that remote baseunits needn't have any means by which to activate
48
!them, because that's what the remotes are there for!
60
linkedtake(self,self.linkto);
62
linkeddrop(self,self.linkto);
65
examine: print "It has a ";
66
if (self has pluslink) print "plus link ";
67
else print "minus link ";
69
if (self.linkto==0) "isn't connected to anything.";
70
else print "is connected to ",(a) self.linkto,".^";
74
if (self hasnt remotely) "Nothing happens.";
75
else "You perceive no other effect.";
77
temporary=self.linkto;
83
if (self hasnt remotely) "Nothing happens.";
84
else "You perceive no other effect.";
86
temporary=self.linkto;
91
if (self hasnt remotely) "Nothing happens.";
92
else "You perceive no other effect.";
94
temporary=self.linkto;
99
with baseunit, turnon, turnoff, brief;
103
linkedtake(self,self.linkto);
105
linkeddrop(self,self.linkto);
108
examine: print "It has a ";
109
if (self has pluslink) print "plus link ";
110
else print "minus link ";
112
if (self.linkto==0) "isn't connected to anything.";
113
else print "is connected to ",(a) self.linkto,".^";
115
with brief, turnon, turnoff, linkto;
120
switchon: print "You flip ",(the) self," on.^";
123
switchoff: print "You flip ",(the) self," off.^";
127
verb "link" "connect" * noun "to" noun -> link;
128
verb "unlink" "disconnect"
131
if (noun has remotely) {
132
print (the) noun," doesn't have a link. It works via ",(the) self.baseunit,".^";
135
if (second has remotely) {
136
print (the) second," doesn't have a link. It works via",
137
(the) second.baseunit,".^";
140
if (noun has pluslink && (second has minuslink)) {
144
if (noun has minuslink && (second has pluslink)) {
148
if (noun has pluslink && (second has pluslink)) {
149
"You can't link those together because they both have plus links.^";
151
if (noun has minuslink && (second has minuslink)) {
152
"You can't link those together because they both have minus links.";
154
if (noun hasnt pluslink && (noun hasnt minuslink)) {
155
print (the) noun," doesn't have a link so you can't link it to anything.^";
158
if (second hasnt pluslink && (second hasnt minuslink)) {
159
print (the) second," doesn't have a link so you can't link anything to it.^";
162
if (noun.linkto~=0) {
163
print (the) noun," is already linked to ",(the) noun.linkto,". You'll
164
have to unlink it first.^";
167
if (second.linkto~=0) {
168
print (the) second," is already linked to ",(the) second.linkto,". You'll
169
have to unlink it first.^";
176
print "You link ",(the) i," to ",(the) j,".^";
177
if (indirectlycontains(player,i) && (indirectlycontains(player,j) == false)) {
178
print "You also let go of ",(the) i,".^";
179
move i to parent(player);
181
if (indirectlycontains(player,i) == false && (indirectlycontains(player,j))) {
182
print "You also let go of ",(the) j,".^";
183
move j to parent(player);
190
if (noun has remotely) {
191
print (the) noun," doesn't have a link. It works via ", (the) noun.baseunit,".^";
195
if (noun provides linkto) {
196
temporary=noun.linkto;
197
if (temporary==0) "That isn't linked to anything.^";
198
print "You unlink ",(the) noun," from ",(the) temporary,".^";
207
else if (noun provides linkto && (second provides linkto)) {
208
if (noun.linkto ~= second) "Those aren't linked together.^";
209
print "You unlink ",(the) noun," from ",(the) second,".^";
217
else if (noun provides ~linkto) {
218
print (the) noun," doesn't have a link.^";
221
else if (second~=0) {
222
if (second provides ~linkto) {
223
print (the) second," doesn't have a link.^";
230
if (i in player) rtrue;
231
if (i has static || (i has scenery)) rtrue;
233
if (runroutines(j,before) ~= 0 || (j has static || (j has scenery))) {
234
print "You'll have to disconnect ",(the) i," from ",(the) j," first.^";
238
if (runroutines(i,before)~=0 || (i has static || (i has scenery))) {
239
print "You'll have to disconnect ",(the) i," from ",(the) j," first.^";
243
if (j hasnt concealed && j hasnt static) move j to player;
244
if (i hasnt static && i hasnt concealed) move i to player;
246
if (runroutines(j,after) ~= 0) rtrue;
247
print "You take ",(the) i," and ",(the) j," connected to it.^";
253
if (i notin player) rtrue;
255
if (runroutines(j,before)~=0) {
256
print "You'll have to disconnect ",(the) i," from ",(the) j," first.^";
260
if (runroutines(i,before)~=0) {
261
print "You'll have to disconnect ",(the) i," from ",(the) j," first.^";
268
if (runroutines(j,after)~=0) rtrue;
269
print "You drop ",(the) i," and ",(the) j," connected to it.^";