-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlib_classes.i
More file actions
2246 lines (1597 loc) · 58.5 KB
/
Copy pathlib_classes.i
File metadata and controls
2246 lines (1597 loc) · 58.5 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- ALAN Standard Library v2.1
-- Classes (file name: 'lib_classes.i')
-- This library file defines various object and actor classes.
-- Many of these classes are frequently used in verb definitions in 'lib_verbs.i'
-- so they should be edited or removed with caution. However, to ease things up,
-- it is mentioned at the beginning of every class below if and where the class
-- is cross-referenced in the other library files.
---- First, we define the default description for scenery objects
-- = no description at all
ADD TO EVERY OBJECT
DESCRIPTION
CHECK THIS IS NOT scenery
ELSE SAY "".
END ADD.
-- Contents:
-- 1. OBJECT CLASSES
-- =================
-- CLOTHING
-- Is a piece of clothing that behaves according to Alan Bampton's 'xwear.i' extension.
-- The said extension has been fully assimilated to this library.
-- This extension prevents clothes from being worn in an illogical order, for example you
-- cannot put on a shirt if you are already wearing a jacket, and so forth.
-- This only applies to the hero; NPCs cannot be made to wear clothing in layers.
-- Also the verbs 'wear', 'remove' and 'undress' are defined here.
-- DEVICE
-- Is a machine or an electronic device, for example a TV. Can be turned
-- (=switched) on and off if it is not broken.
-- Attributes: 'on' and NOT 'on', NOT broken.
-- Is described by default as being either on or off when examined.
-- DOOR
-- Can be opened, closed, and optionally locked and unlocked.
-- Is by default not open, not lockable.
-- all default attributes: openable, NOT open, NOT lockable, NOT locked; not takeable.
-- Is described by default as being either open or closed when examined.
-- LIQUID
-- Can only be taken if it is in a container. You can fill something with it,
-- and you can pour it somewhere.
-- A liquid is by default NOT drinkable.
-- LIGHTSOURCE
-- IS natural or NOT natural
-- (a natural lightsource is for example a match or a torch).
-- Can be turned on and off, lighted and extinguished (= put out) if it
-- is not broken. A natural lightsource
-- cannot be turned on or off, it can only be lighted and extinguished (= put out).
-- When examined, a lightsource is automatically supplied with a description of
-- whether it is providing light or not.
-- LISTED_CONTAINER
-- Is a container object. The contents of a listed_container will be listed both after
-- 'look' (= in the room description), 'look in' and 'examine' (if the container is open).
-- (The contents of a normal container object are not listed after 'examine' by default, but only
-- after 'look' (=room description) and 'look in').
-- SOUND
-- Can be listened to but not examined, searched, smelled or manipulated.
-- (Can be turned on and off if desirable.)
-- SUPPORTER
-- You can put things on this and you can stand on this. It is declared a container,
-- so you can take things from it, as well. When there's something on a supporter,
-- a default listing of it will appear in the room description and after 'examine'.
-- WEAPON
-- IS fireable (for example a cannon) or NOT fireable (for example a baseball bat).
-- WINDOW
-- Can be opened, closed, looked through and out of.
-- Will be by default described as being either open or closed when examined.
-- 2. ACTOR CLASSES
-- ================
-- the ACTORS are defined to be NOT inanimate CONTAINERS (so that they can for example
-- receive and carry things.
--
-- Actors are usually preceded by an article in-game:
-- for example "You see a man here."
-- "There is nothing special about the dog."
-- unless they are declared as 'named'.
--
-- The following classes for actors are defined in this library:
-- PERSON
-- is able to talk (= 'CAN talk').
-- FEMALE
-- a subclass of person (= is able to talk)
-- can be referred to with the pronoun 'her'
-- MALE
-- a subclass of person (= is able to talk)
-- can be referred to with the pronoun 'him'
-- The contents end here.
-- =============================================================
-- =============================================================
--
-- 1. Object classes
--
-- =============================================================
-- =============================================================
-- ==============================================================
----- CLOTHING
-- ==============================================================
-- (See the file 'lib_verbs.i', verbs 'inventory' and 'take' where the
-- container 'worn', defined below, is used in the verb definitions.)
-- To use this class, see the documentation text right after the
-- code below.
-- This class makes use of Alan Bampton's 'xwear.i' extension
-- written originally for ALAN V2, converted here to V3 and
-- assimilated fully to the present library. Thanks to Alan Bampton
-- for the permission to use the code here.
-----------------------------------------------------------------
-- First, we declare the container for clothing.
-----------------------------------------------------------------
-- An entity is present everywhere and thus the hero's clothing is always accessible.
-- This container is only used internally in the library; ignore.
THE worn ISA ENTITY
CONTAINER TAKING CLOTHING.
HEADER SAY hero_worn_header OF my_game.
ELSE SAY hero_worn_else OF my_game.
END THE.
-------------------------------------------------------------------
-- Now, we define some common attributes for clothing as well as
-- how the verbs 'remove', 'undress' and 'wear' (and their synonyms) behave with this class.
-------------------------------------------------------------------
EVERY clothing ISA OBJECT
IS wearable.
IS sex 0.
IS headcover 0.
IS handscover 0.
IS feetcover 0.
IS topcover 0.
IS botcover 0.
IS NOT donned. -- not in the 'wearing' set of any actor; this attribute
-- is used internally in the library; ignore
INITIALIZE
-- the set attribute 'IS wearing' is defined to work for both the hero
-- and NPCs:
IF THIS IN worn
THEN INCLUDE THIS IN wearing OF hero.
END IF.
FOR EACH ac ISA ACTOR
DO
IF ac = hero
THEN
IF THIS IN wearing OF hero AND THIS <> null_clothing
THEN
IF THIS NOT IN worn
THEN LOCATE THIS IN worn.
END IF.
MAKE THIS donned.
END IF.
ELSIF THIS IN wearing OF ac AND THIS <> null_clothing
THEN
IF THIS NOT IN ac
THEN
LOCATE THIS IN ac.
END IF.
MAKE THIS donned.
END IF.
END FOR.
-- all objects found in a piece of clothing, for example a wallet in a jacket,
-- will be allowed back in the piece of clothing once taken from there:
FOR EACH o ISA OBJECT, DIRECTLY IN THIS
DO
INCLUDE o IN allowed OF THIS.
END FOR.
-- all clothing acquired and worn by the hero or an NPC mid-game is checked to
-- show correctly when the possessions of an actor are listed:
SCHEDULE worn_clothing_check AFTER 0.
CONTAINER
-- to allow for example a wallet to be put into a jacket
-- If the clothing contains something, for example if a jacket contains a wallet,
-- the wallet will be mentioned by default when the jacket is examined:
VERB examine
DOES AFTER
IF THIS IS NOT OPAQUE
THEN
IF COUNT ISA OBJECT, DIRECTLY IN THIS > 0
THEN LIST THIS.
END IF.
END IF.
END VERB examine.
VERB wear
CHECK sex OF THIS = sex OF hero OR sex OF THIS = 0
ELSE SAY check_clothing_sex OF my_game.
DOES ONLY
--------------------------------------------------------------------
-- 'wear_flag' is a multi-purpose flag used for several purposes in
-- this library, here it is reset to 0 before proceeding as a matter
-- of 'housekeeping' for the code.
--------------------------------------------------------------------
SET wear_flag OF hero TO 0.
--------------------------------------------------------------------
-- First check to see if the player is carrying the item already, if
-- not, set the 'wear_flag' to 1 to indicate the item was picked up
-- in this turn.
--------------------------------------------------------------------
IF THIS NOT IN hero
THEN
SET wear_flag OF hero TO 1.
END IF.
--------------------------------------------------------------------
-- Now see if the player can put this item on by testing
-- all of its coverage attributes against the player's state.
--------------------------------------------------------------------
--------------------------------------------------------------------
-- First check the 'topcover' attributes, if 'obj' fails this test
-- then it means the hero is already wearing clothes that cover the
-- topcover area and those clothes are of the same layer or a layer
-- that belongs on top of the 'obj' item. In either case it would
-- NOT be possible to put on the 'obj'. To 'flag' this condition add
-- 5 to the 'wear_flag' attribute as an indicator this test failed.
--------------------------------------------------------------------
IF topcover OF THIS <> 0 AND topcover OF THIS <= SUM OF topcover DIRECTLY IN worn
THEN
INCREASE wear_flag OF hero BY 5.
END IF.
--------------------------------------------------------------------
-- Perform a similar test for other attributes.
--------------------------------------------------------------------
IF handscover OF THIS <> 0 AND handscover OF THIS <= SUM OF handscover DIRECTLY IN worn
THEN
INCREASE wear_flag OF hero BY 5.
END IF.
IF feetcover OF THIS <> 0 AND feetcover OF THIS <= SUM OF feetcover DIRECTLY IN worn
THEN
INCREASE wear_flag OF hero BY 5.
END IF.
IF headcover OF THIS <> 0 AND headcover OF THIS <= SUM OF headcover DIRECTLY IN worn
THEN
INCREASE wear_flag OF hero BY 5.
END IF.
--------------------------------------------------------------------
-- botcover is a special case, adjust the 'tempcovered OF hero'
-- attribute so that the code rejects non sensible options.
-- First of all, discount any coatlike clothes as these never
-- affect ability to put on other lower body only garments.
--------------------------------------------------------------------
SET tempcovered OF hero TO SUM OF botcover DIRECTLY IN worn.
IF tempcovered OF hero >63 and botcover OF THIS < 33
THEN
SET tempcovered OF hero TO tempcovered OF hero -64.
END IF.
--------------------------------------------------------------------
-- Now discount any dress/ skirt coverall like clothes as these do
-- not technically affect ability to put on lower body only clothes.
-- Special clause here excludes the full body coverage 'teddy' type
-- garment - as a skirt WOULD prevent that from being removed.
-- ( dress/coat garments automatically prevent this by virtue of
-- having higher 'topcover' settings than the teddy )
--------------------------------------------------------------------
IF tempcovered OF hero >31 AND botcover OF THIS < 16 and botcover OF THIS <> 4
THEN
SET tempcovered OF hero TO tempcovered OF hero -32.
END IF.
--------------------------------------------------------------------
-- IF tempcovered OF hero is still > 15 then must have trousers
-- type clothing on - therefore disallow wearing dress type clothing
-- because, although technically possible, it is not very sensible.
--------------------------------------------------------------------
IF tempcovered OF hero >15 AND botcover OF THIS > 16
THEN
SET tempcovered OF hero TO tempcovered OF hero +16.
END IF.
--------------------------------------------------------------------
-- From here down, clothes DO work as they do for other areas.
--------------------------------------------------------------------
IF botcover OF THIS <> 0 AND botcover OF THIS <= tempcovered OF hero
THEN
INCREASE wear_flag OF hero BY 5.
END IF.
--------------------------------------------------------------------
-- At this point, 'wear_flag' will be 0 if the obj was held by the
-- player and can be put on, or l if he picked it up this turn and
-- it can be put on. Any higher value means one or more of the
-- tests failed and the player cannot put on these clothes.
--------------------------------------------------------------------
IF wear_flag OF hero >1
THEN
-- -------------------------------
-- The clothing item can't be worn
-- -------------------------------
IF THIS NOT IN hero
-- >>> implicit taking: >>>
THEN "You pick up" SAY THE THIS. "."
END IF.
LOCATE THIS IN hero.
-- <<< implicit taking. <<<
LIST worn.
"Trying to put" SAY THE THIS. "on isn't very sensible."
ELSE
-- -----------------------------
-- The clothing item can be worn
-- -----------------------------
MAKE THIS donned.
LOCATE THIS IN worn.
INCLUDE THIS IN wearing OF hero.
IF wear_flag OF hero = 1
THEN
-- --------------------------
-- The item is taken and worn
-- --------------------------
"You pick up" SAY THE THIS.
IF THIS IS NOT plural
THEN "and put it on."
ELSE "and put them on."
END IF.
ELSE
-- -----------------------
-- The item is simply worn
-- -----------------------
"You put on" SAY THE THIS. "."
END IF.
END IF.
END VERB wear.
VERB remove
CHECK THIS IN worn
ELSE SAY check_obj_in_worn OF my_game.
AND CURRENT LOCATION IS lit
ELSE SAY check_current_loc_lit OF my_game.
DOES ONLY
SET wear_flag OF hero TO 0.
--------------------------------------------------------------------
-- Check the total 'topcover' of items worn. Because of the number
-- sequence used, by dividing the sum of the worn attributes by two
-- and then comparing the result to the individual 'topcover' of the
-- obj in question, ( the former can only ever be greater than the
-- latter if an article of clothing is worn that goes over 'obj' )
-- it's easy to tell if the obj ought to be removable. A temporary
-- attribute is used here because it needs to be manipulated. Once
-- again 'wear_flag' is used to indicate the results.
--------------------------------------------------------------------
SET tempcovered OF hero TO SUM OF topcover DIRECTLY IN worn /2.
IF topcover OF THIS <> 0 AND topcover OF THIS < tempcovered OF hero
THEN
INCREASE wear_flag OF hero BY 1.
END IF.
--------------------------------------------------------------------
-- Perform a similar test for other attributes.
--------------------------------------------------------------------
SET tempcovered OF hero TO SUM OF handscover DIRECTLY IN worn /2.
IF handscover OF THIS <> 0 AND handscover OF THIS < tempcovered OF hero
THEN
INCREASE wear_flag OF hero BY 1.
END IF.
SET tempcovered OF hero TO SUM OF feetcover DIRECTLY IN worn /2.
IF feetcover OF THIS <> 0 AND feetcover OF THIS < tempcovered OF hero
THEN
INCREASE wear_flag OF hero BY 1.
END IF.
SET tempcovered OF hero TO SUM OF headcover DIRECTLY IN worn /2.
IF headcover OF THIS <> 0 AND headcover OF THIS < tempcovered OF hero
THEN
INCREASE wear_flag OF hero BY 1.
END IF.
--------------------------------------------------------------------
-- botcover is a special case - first discount any coatlike clothes
-- as these do not affect ability to take off other lower garments.
--------------------------------------------------------------------
SET tempcovered OF hero TO SUM OF botcover DIRECTLY IN worn.
IF tempcovered OF hero >63
THEN
SET tempcovered OF hero TO tempcovered OF hero -64.
END IF.
--------------------------------------------------------------------
-- Now discount any dress/ skirt coverall like clothes as these do
-- not affect ability to take off other lower garments. The 'teddy'
-- type garment is expressly NOT included in the exclusion here.
--------------------------------------------------------------------
IF tempcovered OF hero >31 and botcover OF THIS <>4
THEN
SET tempcovered OF hero TO tempcovered OF hero -32.
END IF.
--------------------------------------------------------------------
-- Now process the manipulated value just as was done for the others
--------------------------------------------------------------------
SET tempcovered OF hero TO tempcovered OF hero /2.
IF botcover OF THIS <> 0 AND botcover OF THIS < tempcovered OF hero
THEN
INCREASE wear_flag OF hero BY 1.
END IF.
--------------------------------------------------------------------
-- Depending on the value of 'wear_flag' print and process the obj
-- as needed. If 'wear_flag' is NOT 0 then the clothes cannot be
-- removed.
--------------------------------------------------------------------
IF wear_flag OF hero > 0
THEN
LIST worn.
"Trying to take" SAY THE THIS. "off isn't very sensible."
ELSE
LOCATE THIS IN hero.
"You take off" SAY THE THIS. "."
EXCLUDE THIS FROM wearing OF hero.
MAKE THIS NOT donned.
END IF.
END VERB remove.
END EVERY.
--------------------------------------------------------------------
-- These attributes are used internally in the library - ignore!
--------------------------------------------------------------------
ADD TO EVERY ACTOR
IS tempcovered 0.
IS wear_flag 0.
IS sex 0.
END ADD TO.
--------------------------------------------------------------------
-- An event checking that clothing acquired and worn by an actor
-- mid-game is recognised to be worn by the actor:
--------------------------------------------------------------------
EVENT worn_clothing_check
FOR EACH ac ISA ACTOR
DO
FOR EACH cl ISA CLOTHING, IN wearing OF ac
DO
IF ac = hero
THEN
IF cl NOT IN worn
THEN LOCATE cl IN worn.
MAKE cl donned.
END IF.
ELSE
IF cl NOT IN ac
THEN LOCATE cl IN ac.
MAKE cl donned.
END IF.
END IF.
END FOR.
END FOR.
SCHEDULE worn_clothing_check AFTER 1.
END EVENT.
--------------------------------------------------------------------
-----------------------------------------------------------------------
-- INSTRUCTIONS FOR USING THE CLOTHING CLASS
-----------------------------------------------------------------------
-- Here is a quick overview for using the class 'clothing'.
-- A piece of clothing in your game code should look
-- something similar to the following four examples:
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- THE jacket ISA CLOTHING AT lobby
-- IS topcover 32.
-- END THE.
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- use IN to refer to containers:
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- THE jeans ISA CLOTHING IN wardrobe
-- IS botcover 16.
-- END THE.
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- IN worn = worn by the player character (hero):
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- THE hat ISA CLOTHING IN hero -- declaring the initial location is optional
-- IS headcover 2.
-- END THE.
--
-- THE hero ISA ACTOR
-- IS wearing {hat}.
-- END THE hero.
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- worn by an NPC called Joe:
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- THE sweater ISA CLOTHING IN joe -- declaring the initial location is optional!
-- -- Don't declare clothing attributes for NPCs (unless the hero is meant to
-- -- take and wear the NPC's clothing). NPCs cannot wear clothing in layers!
-- END THE.
--
-- THE joe ISA ACTOR AT room1
-- IS wearing {sweater}.
-- END THE joe.
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Note that if the piece of clothing worn by an NPC is not meant to be takeable
-- by the player character, you should declare the the piece of clothing to be
-- NOT takeable.
-- In defining a piece of clothing, you should
--
-- 1) define it ISA CLOTHING (and not: ISA OBJECT)
--
-- 2) give it one of five attributes 'headcover', 'topcover', botcover',
-- 'footcover' or 'handcover'; sometimes two of these are needed.
-- Which attribute(s) to use depends on the type of clothing; see the clothing
-- table below.
-- 3) A number 2, 4, 8, 16, 32 or 64 needs to be added after the above attribute.
-- You cannot decide the number yourself; look it up from the clothing table
-- below. If the value of an attribute for a piece of clothing is 0 in the
-- table, don't mention this attribute in connection with your clothing object.
-- If the piece of clothing is initially worn by either the hero or another actor,
-- the attribute 'IS wearing', followed by the piece(s) of clothing in curly brackets,
-- is needed at the respective actor instance:
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- THE hero ISA ACTOR
-- IS wearing {jeans, shirt, flipflops}.
-- END THE hero.
--
-- THE jill ISA ACTOR
-- IS wearing {dress}.
-- END THE jill.
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- The above is enough; the rest is then handled automatically by the library.
-- The quick guide ends here.
-- The clothing table
-----------------------
-- Here is the chart showing a selection of fairly typical clothing items and the values to
-- set to obtain appropriate behaviour. Should you wish to create an article of clothing not
-- listed, usually a bit of lateral thought as to what it is most like and where it fits into
-- the scheme of things will suggest a workable set of values, but be aware that you MUST use
-- values in this chart, simply adding things with intermediate values is probably going to
-- create nasty bugs:
--+--------------------------+----------+----------+-----------+------------+
--| Clothing | Headcover | Topcover | Botcover | Feetcover | Handscover |
--+--------------------------+----------+----------+-----------+------------+
--| hat 2 | 0 | 0 | 0 | 0 |
--| vest/bra 0 | 2 | 0 | 0 | 0 |
--| undies/panties 0 | 0 | 2 | 0 | 0 |
--| teddy 0 | 4 | 4 | 0 | 0 |
--| blouse/shirt/T-shirt 0 | 8 | 0 | 0 | 0 |
--| dress/coveralls 0 | 8 | 32 | 0 | 0 |
--| skirt 0 | 0 | 32 | 0 | 0 |
--| trousers/shorts 0 | 0 | 16 | 0 | 0 |
--| sweater/pullover 0 | 16 | 0 | 0 | 0 |
--| jacket 0 | 32 | 0 | 0 | 0 |
--| coat 0 | 64 | 64 | 0 | 0 |
--| socks/stockings 0 | 0 | 0 | 2 | 0 |
--| tights/pantiehose 0 | 0 | 8 | 2 | 0 |
--| shoes/boots 0 | 0 | 0 | 4 | 0 |
--| gloves 0 | 0 | 0 | 0 | 2 |
--+--------------------------+----------+----------+-----------+------------+
-- =============================================================
----- DEVICE
-- =============================================================
-- (This class is not cross-referenced elsewhere in this or any other library file.)
EVERY device ISA OBJECT
VERB examine
DOES AFTER
IF THIS IS NOT plural
THEN "It is"
ELSE "They are"
END IF.
IF THIS IS 'on'
THEN "currently on."
ELSE "currently off."
END IF.
END VERB examine.
VERB turn_on
CHECK THIS IS NOT 'on'
ELSE
IF THIS IS NOT plural
THEN SAY check_device_not_on_sg OF my_game.
ELSE SAY check_device_not_on_pl OF my_game.
END IF.
AND CURRENT LOCATION IS lit
ELSE SAY check_current_loc_lit OF my_game.
AND THIS IS reachable AND THIS IS NOT distant
ELSE
IF THIS IS NOT reachable
THEN
IF THIS IS NOT plural
THEN SAY check_obj_reachable_sg OF my_game.
ELSE SAY check_obj_reachable_pl OF my_game.
END IF.
ELSIF THIS IS distant
THEN
IF THIS IS NOT plural
THEN SAY check_obj_not_distant_sg OF my_game.
ELSE SAY check_obj_not_distant_pl OF my_game.
END IF.
END IF.
AND THIS IS NOT broken
ELSE SAY check_obj_not_broken OF my_game.
DOES ONLY
"You turn on" SAY THE THIS. "."
MAKE THIS 'on'.
END VERB turn_on.
VERB turn_off
CHECK THIS IS 'on'
ELSE
IF THIS IS NOT plural
THEN SAY check_device_on_sg OF my_game.
ELSE SAY check_device_on_pl OF my_game.
END IF.
AND CURRENT LOCATION IS lit
ELSE SAY check_current_loc_lit OF my_game.
AND THIS IS reachable AND THIS IS NOT distant
ELSE
IF THIS IS NOT reachable
THEN
IF THIS IS NOT plural
THEN SAY check_obj_reachable_sg OF my_game.
ELSE SAY check_obj_reachable_pl OF my_game.
END IF.
ELSIF THIS IS distant
THEN
IF THIS IS NOT plural
THEN SAY check_obj_not_distant_sg OF my_game.
ELSE SAY check_obj_not_distant_pl OF my_game.
END IF.
END IF.
DOES ONLY
"You turn off" SAY THE THIS. "."
MAKE THIS NOT 'on'.
END VERB turn_off.
-- The following verb switches a device off if the device is on, and vice versa.
VERB switch
CHECK CURRENT LOCATION IS lit
ELSE SAY check_current_loc_lit OF my_game.
AND THIS IS reachable AND THIS IS NOT distant
ELSE
IF THIS IS NOT reachable
THEN
IF THIS IS NOT plural
THEN SAY check_obj_reachable_sg OF my_game.
ELSE SAY check_obj_reachable_pl OF my_game.
END IF.
ELSIF THIS IS distant
THEN
IF THIS IS NOT plural
THEN SAY check_obj_not_distant_sg OF my_game.
ELSE SAY check_obj_not_distant_pl OF my_game.
END IF.
END IF.
AND THIS IS NOT broken
ELSE SAY check_obj_not_broken OF my_game.
DOES ONLY
IF THIS IS 'on'
THEN "You switch off" SAY THE THIS. "."
MAKE THIS NOT 'on'.
ELSE "You switch on" SAY THE THIS. "."
MAKE THIS 'on'.
END IF.
END VERB switch.
END EVERY.
-- =============================================================
----- DOOR
-- =============================================================
-- (This class is not cross-referenced elsewhere in this or any other library file.)
EVERY door ISA OBJECT
IS openable.
IS NOT open.
IS NOT lockable.
IS NOT locked.
IS NOT takeable.
HAS otherside null_door.
-- The other side of the door in the next room will be automatically taken care
-- of so that it shows correctly in any room or object descriptions.
-- 'null_door' is a dummy default that can be ignored.
INITIALIZE
-- ensuring that the author didn't forget to declare a locked door closed
-- (= NOT open), as well. This is just double-checking, as any door is by
-- default closed (= "NOT open") at the start of the game:
IF THIS IS locked
THEN
IF THIS IS open
THEN MAKE THIS NOT open.
END IF.
END IF.
-- ensuring that if a door has an otherside attribute declared, this
-- otherside will have the original door as its otherside in turn:
IF otherside OF THIS <> null_door
THEN
SET otherside OF otherside OF THIS TO THIS.
-- next, ensuring that some attributes are correctly assigned to the
-- otherside of the door, as well. Only some non-default cases need to be
-- addressed here:
IF THIS IS NOT openable
THEN MAKE otherside OF THIS NOT openable.
END IF.
IF THIS IS open
THEN MAKE otherside OF THIS open.
END IF.
IF THIS IS lockable
THEN MAKE otherside OF THIS lockable.
END IF.
IF THIS IS locked
THEN MAKE otherside OF THIS locked.
END IF.
END IF.
-- making the same matching_key open both sides of a door:
IF otherside OF THIS <> null_door AND matching_key OF THIS <> null_key
THEN SET matching_key OF otherside OF THIS TO matching_key OF THIS.
END IF.
-- If a door is lockable/locked, you should state at the door instance which
-- object will unlock it, with the matching_key attribute. For example:
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- THE attic_door ISA DOOR
-- HAS matching_key brass_key.
-- ...
-- END THE.
--
-- THE brass_key ISA OBJECT AT basement
-- END THE.
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- (null_key is a default dummy object that can be ignored.)
VERB examine
DOES AFTER
IF THIS IS NOT plural
THEN "It is"
ELSE "They are"
END IF.
"currently"
IF THIS IS NOT open
THEN "closed."
ELSE "open."
END IF.
END VERB examine.