-
Notifications
You must be signed in to change notification settings - Fork 5
/
evenchur.lua
1629 lines (1550 loc) · 49 KB
/
evenchur.lua
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
local Inv = {}
Inv.mt = {
__index = Inv,
}
local colors = {
reset = "\x1b[m",
prompt = "\x1b[1;37m",
item = "\x1b[1;36m",
status = "\x1b[32m",
problem = "\x1b[33m",
error = "\x1b[1;31m",
extreme = "\x1b[1;37;45;5m",
debug = "\x1b[34m",
npc = {
good = "\x1b[1;32m",
bad = "\x1b[1;35m",
}
}
colors.big_problem = colors.error
local dup_success = {
"Your stack of $OBJECT grows.",
"You have another $OBJECT.",
"You get another $OBJECT.",
}
local mat_success = {
"You suddenly find yourself in possession of $A $OBJECT.",
"$A $OBJECT appears on your person.",
"$A $OBJECT materializes out of thin air.",
}
local trans_empty = {
"Where do you want to go?",
"Where are you going?",
}
local mark_no_wb = {
"You don't see any whiteboards for you to use this on.",
"You don't see an appopriate drawing surface for this.",
}
local go_fail = {
"You cannot go $DIRECTION.",
"Your passage $DESCR is blocked.",
"A wall greets you $DESCR.",
"The path $DESCR is impassible.",
}
local go_empty = {
"Go where?",
"Go which direction?",
"Where are you going?",
}
local go_immobile = {
"You find that you can't move.",
"You can't move!",
"For some reason, you can't move.",
}
local use_empty = {
"Use what?",
"Use which?",
"What will you use?",
}
local bad_name = {
"I'm not sure what $A $OBJECT is.",
"What's $A $OBJECT?",
"I don't know what $A $OBJECT is.",
}
local not_in_inv = {
"You don't have $A $OBJECT.",
"You have no $OBJECT.",
"You don't find $A $OBJECT on your person.",
}
local use_not_useful = {
"The $OBJECT doesn't seem useful.",
"You can't find out how to use the $OBJECT.",
}
local use_ext_not_useful_except_inv = {
"It seems like the $OBJECT would be more useful if you were lugging it around.",
"How do you use $A $OBJECT from across the room?",
"Maybe you should try picking up the $OBJECT."
}
local use_ext_not_useful = {
"The $OBJECT doesn't seem useful.",
"You can't find out how to use the $OBJECT.",
}
local use_ext_not_useful_stupid = {
"Please find the nearest real-world instance of $A $OBJECT, and ask somebody how to use it.",
"Maybe you should read an instruction manual for $A $OBJECT.",
"You know, maybe you're going about this the wrong way.",
"Have you ever seen $A $OBJECT used in real life?",
}
local use_no_used = {
"Use what on that?",
"What are you using on that?",
"What will you use on that?",
}
local used_empty = {
"What do you want to use this on?",
"What thing do you want to use this with?",
}
local take_empty = {
"Take what?",
"Take which?",
"What are you taking?",
}
local take_room_empty = {
"There is nothing here.",
"You can't take anything because there's nothing here.",
"There is nothing here for you to take.",
}
local take_no_item = {
"There are no $OBJECTs here.",
"You can't find $A $OBJECT in here.",
"Not a single $OBJECT can be found.",
}
local take_success = {
"You take $A $OBJECT.",
"You take a single $OBJECT.",
}
local take_object_static = {
"The $OBJECT is fixed to the floor.",
"The $OBJECT is stuck.",
"You can't budge the $OBJECT.",
"The $OBJECT won't move.",
}
local take_too_heavy = {
"You can't carry the $OBJECT because it's too heavy.",
"You can't carry $A $OBJECT; you're already carrying too much.",
"You're already holding too much to carry the $OBJECT.",
}
local put_empty = {
"Put what?",
"Put which?",
"What are you putting down?",
}
local put_no_dest = {
"You can't find $A $OBJECT to put that into.",
"There's no $OBJECT for you to put that into.",
}
local put_no_inv = {
"The $OBJECT doesn't have any space for you to put that.",
"The $OBJECT can't accept that.",
"There's no place in the $OBJECT for you to put that.",
}
local put_success = {
"You put the $OBJECT down.",
"You place the $OBJECT in the room.",
}
local put_success_into = {
"You put the $OBJECT into the $DEST.",
"You place the $OBJECT into the $DEST.",
"You gently shove the $OBJECT into the $DEST.",
}
local cs_names = {
"THE MAINFRAME OF EXISTENCE EMITS INCOMPREHENSIBLE MELODIES WHICH BEGIN THE UNIVERSE." ,
"THE VERY FABRIC OF BEING BENDS TO YOUR BECK AND CALL.",
"THE AIR IS HEAVY WITH THE SCENT OF OMNISCIENCE.",
"YOU FEEL THE TOUCH OF ANOTHER UNIVERSE SPINNING INTO EXISTENCE. IT IS RIGHT AND GOOD.",
}
local cs_err = {
"YOU IMPUGN THE NATURE OF BEING WITH YOUR BROKEN PROGRAMS. IT TELLS YOU THAT YOU SHOULD BE ASHAMED. YOU ARE NOW ASHAMED.",
"THE BENEVOLENT CONSTITUENTS OF EVERYTHING GLADLY ASSIST YOU IN PRETENDING THAT YOU NEVER WROTE SUCH ERRANT CODE.",
"YOU WHISPER SWEET IMPOSSIBILITIES OF LOGIC INTO THE VOID OF PURE NOTHING, WHERE THEY HARMLESSLY VANISH INSTEAD OF TEARING THE UNIVERSE ASUNDER.",
}
local cs_success = {
"YOU WHISPER TO THE UNIVERSE, AND IT WHISPERS BACK TO YOU: $RESULT",
"AS IF IT HAD BEEN A FACT OF EXISTENCE THE ENTIRE TIME, A $RESULT POPS INTO YOUR MIND.",
"AN INFINITE HIERARCHY OF STRUCTURE BEARS DOWN UPON THEE AND CALLS $RESULT INTO EXISTENCE.",
}
local hd_empty = {
"You stare blanky at the " .. colors.item .. "hammerdrill" .. colors.reset .. " in $RAWROOM.",
"The " .. colors.item .. "hammerdrill" .. colors.reset .. " beckons from within $RAWROOM.",
"You're in $RAWROOM, holding a " .. colors.item .. "hammerdrill" .. colors.reset .. ".",
}
local hd_no_name = {
"As much as you'd like to, you cannot fathom breaking this wall into a nameless room.",
"You hesitate, thinking about the name of the room you're about to break into.",
"A room on the other side of the wall beckons your drill, but you might want to give it a name.",
}
local hd_wrong_name_type = {
"You're pretty sure you can only give one name to a room.",
"It seems odd that a room would have multiple names.",
"That room probably doesn't have that many names.",
}
local hd_no_dir = {
"You're not sure which wall to drill.",
"Which direction do you want to go?",
"What direction are you drilling in?",
}
local hd_wrong_dir_type = {
"You're pretty sure you can't drill in multiple directions at once.",
"Choose one, and only one, direction to drill in.",
"Out of those, which singular direction do you actually want to drill in?",
}
local hd_bad_reverse = {
"You would carve a link $DESC, but you can't figure out what the reverse direction would be (try 'norvs true' or 'noreverse true').",
"You can't figure out what the opposite of $DIR is (try 'norvs true' or 'noreverse true').",
}
local hd_success = {
"You smash through the wall and find $ROOM on the other side.",
"After some loud drilling, you create a passage to $ROOM.",
"As the chips of concrete fall and the dust subsides, $ROOM peeks through the new hole.",
}
local tino_kills = {
"administers a Tino exam!",
"hits you with a log!",
"summons a dragon!",
"pulverizes you!",
"measures you!",
}
local shell_no_code = {
"You look dumbly at the terminal. A Lua prompt blinks dumbly back at you.",
"The Lua prompt doesn't know what to run.",
}
local shell_syntax_err = {
"Before it can even run, Lua flatly responds: $ERROR",
"The Lua prompt looks at you, unmoved, and says $ERROR.",
"With a total lack of comprehension, the Lua prompt only manages: $ERROR",
}
local shell_runtime_err = {
"The Lua you wrote was malignant, due to $ERROR.",
"Lua tried your program, but crashed with $ERROR.",
"All looked well until $ERROR happened.",
}
local shell_success = {
"The shell dutifully responds to you: $RESULT",
"Almost immediately, the Lua prompt spits $RESULT back at you.",
"A $RESULT is made available to you.",
}
local vowel = {
a = true,
e = true,
i = true,
o = true,
u = true,
}
local link_alias = {
n = "north",
s = "south",
e = "east",
w = "west",
u = "up",
d = "down",
}
local link_reverse = {
north = "south",
south = "north",
east = "west",
west = "east",
up = "down",
down = "up",
}
local link_desc = setmetatable({
north = "to the north",
south = "to the south",
east = "to the east",
west = "to the west",
up = "above you",
down = "below you",
}, {__index = function(s, k)
local v = 'to the ' .. k
s[k] = v
return v
end})
local prepositions = {
on = true,
["in"] = true,
with = true,
from = true,
}
local function to_key_values(rest)
local ret = {}
local k = nil
for idx, word in ipairs(rest) do
if word == "and" then
-- pass
else
if k ~= nil then
if ret[k] ~= nil then
if type(ret[k]) ~= "table" then
ret[k] = {ret[k]}
end
table.insert(ret[k], word)
else
ret[k] = word
end
k = nil
else
k = word
end
end
end
return ret
end
local game
function Inv.new()
return setmetatable({}, Inv.mt)
end
setmetatable(Inv, {__call = function(...) return Inv.new() end})
function Inv:clone()
local new = Inv()
for k, v in pairs(self) do new[k] = v end
return new
end
function Inv:get(item)
local amt = self[item]
if amt == nil then amt = 0 end
return amt
end
function Inv:add(item, num)
local amt = self:get(item)
amt = amt + num
if amt <= 0 then
self[item] = nil
else
self[item] = amt
end
end
function Inv:is_empty()
return next(self) == nil
end
function Inv:total_weight()
local sum = 0
for k, v in pairs(self) do
local obj = game.objects[k]
if obj ~= nil and obj.weight ~= nil then
sum = sum + obj.weight * v
end
end
return sum
end
local Room = {}
Room.mt = {
__index = Room,
}
function Room.from(obj)
if obj == nil then return nil end
return setmetatable(obj, Room.mt)
end
setmetatable(Room, {__call = function(_room, obj) return Room.from(obj) end})
function Room:get_inv()
if self.inv == nil then self.inv = Inv() end
return self.inv
end
function Room:get_links()
if self.links == nil then self.links = {} end
return self.links
end
function detect_inv_cycle(obj, seen)
if obj.inv then
for oname, amt in pairs(obj.inv) do
local iobj = game.objects[oname]
if seen[iobj] then return true end
seen[iobj] = true
if detect_inv_cycle(iobj, seen) then return true end
end
end
return false
end
function describe_npc(npc)
return colors.npc[npc.dispos] .. npc.name .. colors.reset
end
local state = {
inv = Inv(),
room = "COSI",
carry_limit = 30,
debug = true,
mode = "evenchur",
cs_err_cnt = 0,
}
function ai_wander(self)
local links = state.get_room(self.room):get_links()
if next(links) == nil then return false end
local dirs = {}
for dir, _ in pairs(links) do
table.insert(dirs, dir)
end
local which = dirs[1 + math.floor(math.random() * #dirs)]
self.room = links[which]
--print(colors.debug .. self.name .. " moves to " .. self.room .. colors.reset)
return true
end
game = {
rooms = {
COSI = {
name = "COSI",
links = {
south = "SC3Hall",
east = "ITL"
},
inv = Inv.clone({
fridge = 1,
chair = 1,
fire_extinguisher = 1,
dumbbell = 1,
vacuum = 1,
}),
},
ITL = {
name = "the ITL",
desc = "There is a class here right now. People are staring at you.",
links = {
south = "SC3Hall",
west = "COSI",
},
},
ServerRoom = {
name = "the server room",
desc = "It is loud and noisy in here; the primary occupants are humming busily.",
links = {
south = "ITL",
},
on_fire = true,
inv = Inv.clone({
duplicator = 1,
materializer = 1,
transporter = 1,
flamethrower = 1,
}),
},
SC3Hall = {
name = "a hallway outside COSI",
desc = "The Science Center's 3rd floor hallway stretches out afore and behind you.",
links = {
north = "COSI",
west = "Concrete",
south = "SC3MBathroom",
east = "SC3Collins",
down = "SC2EastStairwell",
},
},
SC3MBathroom = {
name = "the men's restroom near COSI",
desc = "Despite the vigilant efforts of Carol, the room has a noticeable odor.",
links = {
north = "SC3Hall",
},
},
SC3JankLanding = {
name = "a small annex with an elevator door",
desc = "You find your yourself in a small room with an open connection to a nearby hallway. You see some equipment no doubt used by the maintainance personnel and, perhaps most importantly, an elevator door.",
links = {
north = "Concrete"
}
},
Concrete = {
name = "Concrete Cafe",
desc = "The Cafe is closed right now. Everything is spotless, except for the pockmark from where a brick crashed through the skylight. A stairwell is tucked behind a corner.",
links = {
east = "SC3Hall",
down = "SC2WestStairwell",
south = "SC3JankLanding",
},
inv = Inv.clone({
fork = 1,
spoon = 1,
}),
},
Outside = {
name = "the outside world",
desc = "It is an overcast, Potsdam day; the clouds are threatening snow, despite being quite warm.",
links = {
north = "Concrete",
},
},
SC3Collins = {
name = "A hallway near Tony Collins' office",
desc = "The hallway corners north and west.",
links = {
west = "SC3Hall",
north = "SC3North",
},
inv = Inv.clone({
key = 1,
}),
},
Collins = {
name = "Tony Collins' office",
desc = "Tony Collins is here; he is looking at you, slightly perplexed as to how you got here.",
links = {
west = "SC3Collins",
},
inv = Inv.clone({
collins = 1,
}),
},
SC3North = {
name = "a hallway near the Chairwell",
desc = "This is the northernmost part of the Science Center's 3rd-floor hallway.",
links = {
south = "SC3Collins",
west = "ChairwellBottom",
},
},
ChairwellBottom = {
name = "the bottom of the Chairwell",
desc = "The ramp goes up to the north.",
links = {
north = "ChairwellTop",
east = "SC3North",
},
},
ChairwellTop = {
name = "the top of the Chairwell",
desc = "The ramp goes down to the south.",
links = {
south = "ChairwellBottom",
},
},
SC2EastStairwell = {
name = "the area one floor below COSI",
desc = "There are stairs going up and down a floor. A poster labelled \"Chemistry\" is on the wall.",
links = {
up = "SC3Hall",
down = "SC1EastStairwell",
east = "OutsidePeplOffice",
west = "SC2Hallway",
},
},
OutsidePeplOffice = {
name = "Outside Peploski's Office",
desc = "You are in the part of Science Center ouside Peploski's Office. There is a door outside, but it's frozen shut.",
links = {
west = "SC2EastStairwell",
south = "PeplOffice",
},
},
PeplOffice = {
name = "Peploski's Office",
desc = "The room is a standard office for a professor. Stochiometry is written on the whiteboard.",
links = {
north = "OutsidePeplOffice",
},
inv = Inv.clone({
whiteboard = 1,
marker = 1,
strange_flask = 1,
}),
},
ComputationalSingularity = {
name = "the Core of the Computational Singularity",
desc = colors.extreme .. cs_names[1] .. colors.reset,
links = {
up = "ServerRoom",
},
},
FreshmenPhysLab = {
name = "the Freshmen Physics Lab",
desc = "There is a lab session currently being held. The TA looks at you while the students work on their labs.",
links = {
north = "SC2WestStairwell",
},
},
SC2WestStairwell = {
name = "the area one floor below Concrete Cafe",
desc = "There are stairs going up and down a floor.",
links = {
south = "FreshmenPhysLab",
up = "Concrete",
east = "SC2Hallway"
}
},
SC2Hallway = {
name = "the hallway between the stairwells",
desc = "", -- Description pending
links = {
south = "ThomasOffice",
west = "SC2WestStairwell",
east = "SC2EastStairwell",
},
},
ThomasOffice = {
name = "Thomas's Office",
desc = "The room is a standard office for a professor. Physics problems are written out on the whiteboard.",
links = {
north = "SC2Hallway",
},
inv = Inv.clone({
whiteboard = 1,
marker = 1,
peculiar_gizmo = 1,
}),
},
SC1EastStairwell = {
name = "the area two floors below COSI",
desc = "There are stairs going up a floor. There are leaves scattered everywhere from a nearby door.",
links = {
up = "SC2EastStairwell",
west = "OutsideFreshmenChemLab",
},
},
OutsideFreshmenChemLab = {
name = "outside the Freshmen Chemistry Lab and Chemistry TA office",
desc = "You are in a typical Science Center hallway. Funny comics dot the walls.",
links = {
south = "FreshmenChemLab",
east = "SC1EastStairwell",
},
},
FreshmenChemLab = {
name = "the Freshmen Chemistry Lab",
desc = "You see some general chemistry being conducted in the room before you. Interesting lab material is drawn on the whiteboard",
links = {
north = "OutsideFreshmenChemLab",
},
inv = Inv.clone({
whiteboard = 1,
marker = 1,
}),
},
},
objects = {
fridge = {name = "refrigerator", desc = "A cold box usually filled with refreshing beverages and tasty victuals.", inv = Inv.clone({moxie = 1}), weight = 20},
moxie = {
name = "Moxie soda",
desc = "The bright orange can's fizzy liquid contents beckon to your parched throat.",
weight = 0.1,
use = function()
state.inv:add("movie", -1)
state.inv:add("empty_moxie", 1)
return "You quaff the sparkling, anise-flavored beverage."
end,
},
empty_moxie = {
name = "empty Moxis soda",
desc = "It is still bright orange, but now an empty, frail can.",
},
fire_extinguisher = {
name = "fire extinguisher",
desc = "It's a full and rather-heavy red cylinder with a nozzle, handle, and safety pin.",
weight = 5,
use = function()
state.inv:add("fire_extinguisher", -1)
state.inv:add("empty_fire_extinguisher", 1)
local res = "You empty the canister all over yourself. You choke up the white dust.\n"
if state.fireproof then
res = res .. "You are still fireproof."
else
state.fireproof = true
res = res .. "You are now fireproof."
end
state.get_room().extinguished = true
return res
end,
},
empty_fire_extinguisher = {
name = "empty fire extinguisher",
desc = "It's a slightly-less-heavy red cylinder wiht a nozzle and handle, covered in a fine white powder.",
weight = 3,
use = function()
state.inv:add("empty_fire_extinguisher", -1)
state.inv:add("fire_extinguisher", 1)
return "Because you need it, and definitely not because some programmer was lazy, Charles Babbage descends from the heavens and refills your fire extinguisher."
end,
},
vacuum = {
name = "vacuum",
desc = "It's a canister model with a small red bin and a long black hose ending in a brush head. It has a long cord, and is quite loud.",
weight = 3,
use = function()
local room = state.get_room()
if room.extinguished then
room.extinguished = nil
return "You clean the white dust from the room. " .. colors.problem .. "It is now vulnerable to flames again." .. colors.reset
elseif state.fireproof then
state.fireproof = nil
return "You clean the white dust from yourself. " .. colors.problem .. "You are vulnerable to the flames again." .. colors.reset
else
if math.random() < 0.05 then
local inv = room:get_inv()
local k = next(inv)
if k ~= nil then
local oname, tpl, obj = get_obj_params(k)
inv:add(oname, -1)
return colors.big_problem .. "While tidying the room, you accidentally suck up " .. tpl.A .. " " .. tpl.OBJECT .. colors.big_problem .. "." .. colors.reset
end
end
return "You tidy the place a bit, without much effect."
end
end,
},
key = {
name = "Sargent key",
desc = "It's a small, brass key with careful bitting, labeled `J`.",
weight = 0.02,
use = function()
local roomf = game.objects.key.per_room[state.room]
if roomf ~= nil then
return roomf()
end
return "You can't seem to find a place to use this."
end,
per_room = {
SC3Collins = function()
state.get_room("SC3Collins"):get_links().east = "Collins"
return "You feel the key turn smoothly in the office door."
end,
Concrete = function()
state.get_room("Concrete"):get_links().south = "Outside"
return "The key turns in the air. A portage in the game opens to the south."
end,
COSI = function()
state.get_room("COSI"):get_links().north = "ServerRoom"
return "With a click, the dead bolt retracts from the server room door."
end,
ITL = function()
state.get_room("ITL"):get_links().north = "ServerRoom"
return "With a click, the dead bolt retracts from the server room door."
end,
},
},
chair = {
name = "green swivel chair",
desc = "It has a back and a lift lever, and rolls across the carpet with ease.",
weight = 2,
inv = Inv.new(),
use = function()
if state.room == "ChairwellTop" then
local ret = "You ride down the chairwell. Wheeeeee!"
if game.objects.chair.inv:total_weight() >= 25 then
ret = ret .. colors.big_problem .. "\nYou quickly find that the chair is too heavy to stop. You crash through the wall into the...server room?" .. colors.reset
state.room = "ServerRoom"
state.get_room("ServerRoom"):get_links().north = "ChairwellBottom"
state.get_room("ChairwellBottom"):get_links().south = "ServerRoom"
state.get_room("ITL"):get_links().north = "ServerRoom"
state.get_room("COSI"):get_links().north = "ServerRoom"
if game.objects.chair.inv:get("fridge") > 0 and game.objects.fridge.inv:get("fork_bomb") > 0 then
ret = ret .. colors.extreme .. "\nA SINGULARITY APPEARS WITHIN THE CONFINES OF THE SERVER ROOM." .. colors.reset
state.get_room("ServerRoom"):get_links().down = "ComputationalSingularity"
end
else
state.room = "ChairwellBottom"
end
return ret
end
return "You stare blankly at the chair. " .. colors.problem .. "It stares back." .. colors.reset
end,
},
collins = {
name = "Tony Collins",
desc = "He is a dapper Australian university president.",
use = function()
return "He turns and glares at you."
end,
},
duplicator = {
name = "Duplicator",
desc = "It appears to be made of bits.",
weight = 0.1,
use = function(rest)
if #rest < 1 then
return choose(used_empty)
end
local oname, tpl, obj = get_obj_params(rest[1])
if obj == nil then
return template(choose(bad_name), tpl)
end
if state.inv:get(oname) < 1 then
return template(choose(not_in_inv), tpl)
end
state.inv:add(oname, 1)
return template(choose(dup_success), tpl)
end,
},
materializer = {
name = "Materializer",
desc = "It appears to be made of bits.",
weight = 0.1,
use = function(rest)
if #rest < 1 then
return choose(used_empty)
end
local oname, tpl, obj = get_obj_params(rest[1])
if obj == nil then
return template(choose(bad_name), tpl)
end
state.inv:add(oname, 1)
return template(choose(mat_success), tpl)
end,
},
transporter = {
name = "Transporter",
desc = "It appears to be made of bits.",
weight = 1.5,
use = function(rest)
if #rest < 1 then return choose(trans_empty) end
state.room = rest[1]
return colors.problem .. "Whoosh!" .. colors.reset
end,
},
shell = {
name = "Shell",
desc = "It appears to be made of bits.",
weight = 0.1,
use = function(rest)
if #rest < 1 then
return colors.problem .. choose(shell_no_code) .. colors.reset
end
local ex = table.concat(rest, " ")
if ex:sub(0, 1) == "=" then ex = "return " .. ex:sub(2) end
local chunk, err = load(ex, "=(shell.use)", 'bt', _ENV)
if chunk == nil then
return colors.problem .. template(choose(shell_syntax_err), {ERROR = colors.big_problem .. tostring(err) .. colors.problem}) .. colors.reset
end
local ok, res = pcall(chunk)
if not ok then
return colors.problem .. template(choose(shell_runtime_err), {ERROR = colors.big_problem .. tostring(res) .. colors.problem}) .. colors.reset
end
return template(choose(shell_success), {RESULT = colors.item .. tostring(res) .. colors.reset})
end,
},
flamethrower = {
name = "Flamethrower",
desc = "It has a tank and a pilot light which is lit.",
weight = 10,
use = function()
local room = state.get_room()
if room.extinguished then
return "A spray of liquid fire spews forth, but the room is already fireproof."
end
state.get_room().on_fire = true
return colors.problem .. "A spray of liquid fire spews forth, covering the room in flame." .. colors.reset
end,
},
dumbbell = {
name = "Dumbbell",
desc = "It's a solid iron bar with large weights on either side.",
weight = 6.8,
},
fork = {
name = "fork",
desc = "It's a small white biodegradable plastic fork.",
weight = 0.03,
use = function(rest)
if #rest < 1 then return choose(used_empty) end
if rest[1] ~= "duplicator" then
return "You can't quite figure out how to do that."
end
if state.inv:get("duplicator") < 1 then
return colors.problem .. "You don't have it yet." .. colors.reset
end
state.inv:add("fork", -1)
state.inv:add("duplicator", -1)
state.inv:add("fork_bomb", 1)
return colors.big_problem .. "You create the " .. colors.item .. "fork_bomb" .. colors.big_problem .. "." .. colors.reset
end,
},
fork_bomb = {
name = "Fork Bomb",
desc = colors.big_problem .. "It radiates with unimaginable power." .. colors.reset,
weight = 0.13,
use = function()
state.fork_bombing = 3
return colors.big_problem .. "What have you done?!" .. colors.reset
end,
},
spoon = {
name = "spoon",
desc = "It's a small white biodegradable plastic spoon.",
weight = 0.04,
use = function(rest)
if #rest < 1 then return choose(used_empty) end
if rest[1] ~= "duplicator" then
return "You can't quite figure out how to do that."
end
if state.inv:get("duplicator") < 1 then
return colors.problem .. "You don't have it yet." .. colors.reset
end
state.inv:add("spoon", -1)
state.inv:add("duplicator", -1)
state.inv:add("spoon_bomb", 1)
return colors.status .. "You create the " ..colors.item .. "spoon_bomb" .. colors.status .. "." .. colors.reset
end,
},
spoon_bomb = {
name = "Spoon Bomb",
desc = colors.status .. "It radiates with imaginable power." .. colors.reset,
weight = 0.13,
use = function()
state.spoon_bombing = 3
return colors.status .. "...What have you done?" .. colors.reset
end,
},
whiteboard = {
name = "Whiteboard",
desc = "Nothing is written on it.",
weight = 0.1,
},
marker = {
name = "Whiteboard marker",
desc = "It is a black `Expo' dry-erase marker.",
weight = 0.02,
use = function(rest)
if state.inv:get("whiteboard") < 1 and state.get_room():get_inv():get("whiteboard") < 1 then
return choose(mark_no_wb)
end
if state.room == 'ComputationalSingularity' then
local ex = table.concat(rest, " ")
if ex:sub(0, 1) == "=" then ex = "return " .. ex:sub(2) end
local chunk, err = load(ex, '=(marker.use)', 'bt', _ENV)
if chunk == nil then
if state.debug then
print(colors.debug .. "The error is: " .. tostring(err) .. colors.reset)
end
state.cs_err_cnt = state.cs_err_cnt + 1
if state.cs_err_cnt >= 3 then game.npcs.tino.room = "ComputationalSingularity" end
return colors.extreme .. choose(cs_err) .. colors.reset
end
local ok, result = pcall(chunk)
if not ok then
if state.debug then
print(colors.debug .. "The error is: " .. tostring(result) .. colors.reset)
end
state.cs_err_cnt = state.cs_err_cnt + 1
if state.cs_err_cnt >= 3 then game.npcs.tino.room = "ComputationalSingularity" end
return colors.extreme .. choose(cs_err) .. colors.reset
end
return colors.extreme .. template(choose(cs_success), {RESULT = colors.item .. tostring(result) .. colors.extreme}) .. colors.reset
end
local was_written = (game.objects.whiteboard.desc ~= "Nothing is written on it.")
if #rest >= 1 then
local msg = "`" .. colors.item .. table.concat(rest, " ") .. colors.reset .. "'"
game.objects.whiteboard.desc = "It says " .. msg .. "."
if was_written then
return "You wipe away the old text with your sleeve, and carefully pen in " .. msg .. "."
else
return "You mark upon the clean surface, " .. msg .. "."
end
else
game.objects.whiteboard.desc = "Nothing is written on it."
if was_written then
return "You wipe the text away with your sleeve, and leave it blank."
else
return "You contemplate how you might write nothing on a blank whiteboard, and discover that you've already succeeded."
end
end
end,
},