-
Notifications
You must be signed in to change notification settings - Fork 0
/
Humanity-Helper.lua
1138 lines (1022 loc) · 39.9 KB
/
Humanity-Helper.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
-- title: Humanity's Helper: Global Mission Begins At Home.
-- author: ronynn
-- desc: Explore your neighbourhood helping others.
-- script: lua
--game states
GINIT=0
GINTRO=1
GFADEOUT=2
GFADEIN=3
GPLAY=4
GOBJECT=5
GRESTART=6
GRESET=7
--constants of commands
CMD={
N=1,S=2,W=3,E=4,UP=5,DOWN=6,IN=7,OUT=8,
TAKE=9,DROP=10,USE=11,OPEN=12,EXAM=13,INV=14,
WAIT=15,TALK=16,DESC=17,PUSH=18
}
--commands defined in gui
GUI={
[1]={n="north",x1=9,y1=121,x2=15,y2=127},
[2]={n="south",x1=9,y1=129,x2=15,y2=135},
[3]={n="west",x1=1,y1=129,x2=7,y2=135},
[4]={n="east",x1=17,y1=129,x2=23,y2=135},
[5]={n="up",x1=1,y1=121,x2=7,y2=127},
[6]={n="down",x1=17,y1=121,x2=23,y2=127},
[7]={n="inside",x1=25,y1=121,x2=38,y2=127},
[8]={n="outside",x1=25,y1=129,x2=38,y2=135},
[9]={n="take object",x1=40,y1=121,x2=56,y2=127},
[10]={n="drop object",x1=40,y1=129,x2=56,y2=135},
[11]={n="use object",x1=58,y1=121,x2=74,y2=127},
[12]={n="open object",x1=58,y1=129,x2=74,y2=135},
[13]={n="examine object",x1=76,y1=121,x2=111,y2=127},
[14]={n="show inventory",x1=76,y1=129,x2=111,y2=135},
[15]={n="wait a turn",x1=113,y1=121,x2=129,y2=127},
[16]={n="talk to object",x1=113,y1=129,x2=129,y2=135},
[17]={n="describe room",x1=131,y1=121,x2=157,y2=127},
[18]={n="push object",x1=131,y1=129,x2=157,y2=135},
}
--item room start with 1..X
INV=0 --item in players inventory
HIDE=-1 --item not yet discovered
VOID=-2 --item destroyed
--game variables
rold=1 --previous visited room
room=1 --current room of player
points=0 --score for the ending
turns=1 --how many turns the player played
--engine variables
ver="Humanity's Helper: GLobal Mission Begins At Home."
t=0 --frame counter for each frame
t0=0 --frame counter for animation
eff=0 --start sprite of fade effect
mx,my,mb=0,0,0 --mouse state
pressed=false --mouse pressing simulation
game=GINIT --game state
LINES={} --drawn lines on screen
SELECTED={} --drawn objects on screen that can be selected
callback=nil --calback function for selected gui action
screen={} --stored cover screen
lastcmd=0 --last clicked command in gui
--here you can set various test to override starting point
function tests()
--room=2
--sobjr(1,INV)
end
--game loop
function TIC()
t=t+1
mx,my,mb=mouse()
--draw
if game==GINIT then
--first initialize
tests()
txt(ver,8)
eventIntro()
txt()
look()
game=GINTRO
elseif game==GINTRO then
--draw intro
if game==GINTRO then
rect(0,129,240,7,1)
print("[press z or x to start the game]",20,130,15,true,1,false)
if anykey() then game=GFADEOUT end
end
elseif game==GFADEOUT then
if t%5==1 then
eff=eff+1
end
if fadeout()==1 then game=GFADEIN end
elseif game==GFADEIN then
map(60,0,30,17,0,0,-1)
drawText()
if t%5==1 then
eff=eff+1
end
if fadein()==1 then game=GPLAY end
elseif game==GPLAY then
--draw screen with scrolling text
map(60,0,30,17,0,0)
drawText()
findGui()
elseif game==GOBJECT then
--draw object selection screen
map(60,0,30,17,0,0)
drawSelection()
findGui()
elseif game==GRESTART then
--dead/win screen
map(60,0,30,17,0,0)
drawText()
if anykey() then game=GRESET end
elseif game==GRESET then
--reset game
if t%5==1 then
eff=eff+1
end
if fadeout()==1 then reset() end
end
end
--return true when any key is pressed
function anykey()
for i=0,7 do
if btnp(i) then return true end
end
return false
end
--fadeout effect
function fadeout()
for j=0,17 do
for i=0,29 do
spr(264-eff,i*8,j*8,15)
end
end
if eff==8 then
eff=0
return 1
else
return 0
end
end
--fadein effect
function fadein()
for j=0,17 do
for i=0,29 do
spr(256+eff,i*8,j*8,15)
end
end
if eff==8 then
eff=0
return 1
else
return 0
end
end
--find selected gui element
function findGui()
--quick move with arrows
if btnp(0) then north() end
if btnp(1) then south() end
if btnp(2) then west() end
if btnp(3) then east() end
--mouse gui interaction
for i=1,#GUI do
g=GUI[i]
if mx>=g.x1 and mx<=g.x2 and my>=g.y1 and my<=g.y2 then
print(g.n,163,125,14,true,1,true)
c=pix(g.x1,g.y1)
for i=g.x1,g.x2 do
for j=g.y1,g.y2 do
if pix(i,j)==c then pix(i,j,14) else pix(i,j,6) end
end
end
if mb==true then
if pressed==false then
pressed=true
game=GPLAY
command(i)
end
end
if mb==false then
pressed=false
end
return
end
end
pressed=false
end
--set state
function sstate(i,v)
STATES[i]=v
end
--get state
function gstate(i)
return STATES[i]
end
--set object room
function sobjr(i,r)
OBJECTS[i].r=r
end
--get object room
function gobjr(i)
return OBJECTS[i].r
end
--set new room direction (ri=room index,dir=CMD.,rto=room to index)
function sroomd(ri,dir,rto)
r=ROOMS[ri]
if dir==CMD.N then
r.n=rto
elseif dir==CMD.S then
r.s=rto
elseif dir==CMD.W then
r.w=rto
elseif dir==CMD.E then
r.e=rto
elseif dir==CMD.UP then
r.u=rto
elseif dir==CMD.DOWN then
r.d=rto
elseif dir==CMD.IN then
r.i=rto
elseif dir==CMD.OUT then
r.o=rto
else
err("Trying to set unknown direction "..dir.." for room "..ri)
end
end
--get direction set in room (ri=room index,dir=CMD.)
function groomd(ri,dir)
r=ROOMS[ri]
d=0
if dir==CMD.N then
d=r.n
elseif dir==CMD.S then
d=r.s
elseif dir==CMD.W then
d=r.w
elseif dir==CMD.E then
d=r.e
elseif dir==CMD.UP then
d=r.u
elseif dir==CMD.DOWN then
d=r.d
elseif dir==CMD.IN then
d=r.i
elseif dir==CMD.OUT then
d=r.o
else
err("Trying to get unknown direction "..dir.." from room "..ri)
end
if d==nil then d=0 end
return d
end
--get count of carried items
function ginvc()
c=0
for i=1,#OBJECTS do
if OBJECTS[i].r==INV then c=c+1 end
end
return c
end
--show dead message
function die(s)
txt ""
txd("And you are dead. GAME OVER. Your helped "..points.." people. And you played for "..turns.." turns. Press z or x to restart.")
game=GRESTART
end
--show win message
function win(s)
txt ""
txi("Congratulations, you finished this game after helping "..points.." people! And you played for "..turns.." turns. Press z or x to restart.")
game=GRESTART
end
--movoment functions
function north() move(ROOMS[room].n,CMD.N) end
function south() move(ROOMS[room].s,CMD.S) end
function west() move(ROOMS[room].w,CMD.W) end
function east() move(ROOMS[room].e,CMD.E) end
function up() move(ROOMS[room].u,CMD.UP) end
function down() move(ROOMS[room].d,CMD.DOWN) end
function inside() move(ROOMS[room].i,CMD.IN) end
function outside() move(ROOMS[room].o,CMD.OUT) end
--execute commands from gui
function command(c)
lastcmd=c
if c==CMD.N then
north()
elseif c==CMD.S then
south()
elseif c==CMD.W then
west()
elseif c==CMD.E then
east()
elseif c==CMD.UP then
up()
elseif c==CMD.DOWN then
down()
elseif c==CMD.IN then
inside()
elseif c==CMD.OUT then
outside()
elseif c==CMD.TAKE then
getSelection(room,room,take,"There is nothing here that can be taken.")
elseif c==CMD.DROP then
getSelection(INV,INV,drop,"You aren't carrying anything.")
elseif c==CMD.USE then
getSelection(room,INV,use,"You don't carry or see anything useable.")
elseif c==CMD.OPEN then
getSelection(room,INV,open,"You don't carry or see anything openable.")
elseif c==CMD.PUSH then
getSelection(room,INV,push,"You don't see anything that can be pushed here.")
elseif c==CMD.TALK then
getSelection(room,room,talk,"You don't see anything to talk to here.")
elseif c==CMD.EXAM then
getSelection(room,INV,examine,"You don't carry or see anything here for examination.")
elseif c==CMD.WAIT then
wait()
elseif c==CMD.DESC then
clearText()
look()
elseif c==CMD.INV then
inventory()
else
txi("Unknown command #"..c)
end
end
--wordwrap
function splittokens(s)
local res = {}
for w in s:gmatch("%S+") do
res[#res+1] = w
end
return res
end
--clears text on screen
function clearText()
LINES={}
end
--draw text on screen
function drawText()
for i=1,#LINES do
s=LINES[i]
print(s.t,6,i*7-2,s.c,true,1,true)
end
end
--write text to screen,max 16 lines and 56chars per line
function txt(str,col)
col=col or 15
str=str or ""
if str=="" then
table.insert(LINES,{t=" ",c=col})
if #LINES>16 then table.remove(LINES,1) end
return
end
li=splittokens(str)
size=0
s=""
for i=1,#li do
word=li[i]
wsiz=#word
if size+wsiz+1<=56 then
s=s..word.." "
size=size+wsiz+1
else
table.insert(LINES,{t=s,c=col})
if #LINES>16 then table.remove(LINES,1) end
s=word.." "
size=wsiz+1
end
end
if s~="" then
table.insert(LINES,{t=s,c=col})
if #LINES>16 then table.remove(LINES,1) end
end
end
--information text
function txi(s) txt(s,9) end
--death text
function txd(s) txt(s,6) end
--searchs what can be selected
function getSelection(r1,r2,cb,msg)
SELECTED={}
for i=1,#OBJECTS do
if OBJECTS[i].r==r1 or OBJECTS[i].r==r2 then
table.insert(SELECTED,i)
end
end
cnt=#SELECTED
if cnt>0 then
if cnt==1 then
cb(SELECTED[1])
else
game=GOBJECT
callback=cb
end
else
txi(msg)
end
end
--show items for selection
function drawSelection()
for i=1,#SELECTED do
o=OBJECTS[SELECTED[i]]
w1=#o.n*4
h1=6
x1=6
y1=i*7-2
x2=x1+w1
y2=y1+h1
if mx>=x1 and mx<=x2 and my>=y1 and my<=y2 then
rect(x1,y1,w1,h1,11)
if mb==true then
game=GPLAY
callback(SELECTED[i])
end
end
print(o.n,x1,y1,14,true,1,true)
end
print(GUI[lastcmd].n,163,125,14,true,1,true)
end
--describe room,items,exits
function look()
--room description
describe()
if game==GRESTART then return end
--what player sees
s=""
for i=1,#OBJECTS do
o=OBJECTS[i]
if o.r==room then
s=separate(s,o.n)
end
end
if s~="" then
txt("You see "..s..".",11)
else
txt("There is nothing here.",11)
end
--where can player go
s=""
r=ROOMS[room]
s=lookExit(s,r.n,CMD.N)
s=lookExit(s,r.s,CMD.S)
s=lookExit(s,r.w,CMD.W)
s=lookExit(s,r.e,CMD.E)
s=lookExit(s,r.u,CMD.UP)
s=lookExit(s,r.d,CMD.DOWN)
s=lookExit(s,r.i,CMD.IN)
s=lookExit(s,r.o,CMD.OUT)
if s~="" then
txt("You can go "..s..".",13)
else
txt("There is no exit here.",13)
end
turn()
end
--get exit description
function lookExit(s,r,cmd)
if r~=nil and r>0 then
s=separate(s,GUI[cmd].n)
end
return s
end
--add separator when concaceating strings
function separate(s,s1)
if s~="" then
s=s..", "
end
s=s..s1
return s
end
--show inventory
function inventory()
s=""
for i=1,#OBJECTS do
o=OBJECTS[i]
if o.r==INV then
s=separate(s,o.n)
end
end
if s~="" then
txt("You are carrying "..s..".",14)
else
txt("You are carrying nothing.",14)
end
end
--move player to new room
function move(r,cmd)
d=GUI[cmd].n
if r~=nil and r>0 then
if eventBeforeMove(room,r)==1 then
clearText()
txt("You are going "..d..".",13)
rold=room
room=r
look()
eventAfterMove(rold,room)
end
else
txd("You can't go "..d.."!")
end
end
--room description
function describe()
eventDescribe(room)
end
--each turn this command happens
function turn()
turns=turns+1
eventTurn()
end
--waiting a turn
function wait()
txt("Waiting...",8)
eventWait()
turn()
end
--object description
function examine(i)
txi("You are examining "..OBJECTS[i].n..".")
eventExamine(i)
turn()
end
--take object
function take(i)
if eventBeforeTake(i)==1 then
o=OBJECTS[i]
o.r=INV
txi("You take the "..o.n..".")
eventAfterTake(i)
end
turn()
end
--drop object
function drop(i)
if eventBeforeDrop(i)==1 then
o=OBJECTS[i]
o.r=room
txi("You drop the "..o.n..".")
eventAfterDrop(i)
end
turn()
end
--use object
function use(i)
if eventUse(i)==1 then
o=OBJECTS[i]
txi("You don't know how to use the "..o.n.." here.")
end
turn()
end
--talk to object
function talk(i)
if eventTalk(i)==1 then
o=OBJECTS[i]
txi("You can't talk to the "..o.n..".")
end
turn()
end
--push object
function push(i)
if eventPush(i) then
o=OBJECTS[i]
txi("You can't push the "..o.n..".")
end
turn()
end
--open object
function open(i)
if eventOpen(i)==1 then
o=OBJECTS[i]
txi("You can't open the "..o.n..".")
end
turn()
end
--------==YOUR GAME CODE GOES HERE==------------
--room exit directions,just use s,n,w,e,u,d,i,o for directions
ROOMS={
[1]={s=2,n=3},
[2]={n=1},
[3]={s=1,n=4},
[4]={s=3,n=5,e=9,w=6},
[5]={s=4},
[6]={w=8,s=7,e=4},
[7]={n=6},
[8]={e=6},
[9]={w=4,d=10},
[10]={s=11,w=14,e=12,u=9},
[11]={n=10},
[12]={e=13,w=10},
[13]={w=12},
[14]={e=10,s=15},
[15]={n=14},
}
--list of objects, define name and room 1..X or INV,HIDE
OBJECTS={
[1]={n="atlas",r=1},
[2]={n="fish",r=3},
[3]={n="soap",r=5},
[4]={n="ball",r=HIDE},
[5]={n="love letter",r=7},
[6]={n="cash",r=HIDE},
[7]={n="ticket",r=HIDE},
[8]={n="the train",r=HIDE},
[9]={n="the table",r=1},
[10]={n="Lory",r=7},
[11]={n="Bathing Man",r=10},
[12]={n="Woman on a bench",r=12},
[13]={n="My Friends",r=13},
[14]={n="An Old Woman",r=15},
[15]={n="A Frog Screaming at People",r=11},
}
--game states as simple number of your choice
STATES={
[1]=0, --
[2]=0, --
}
--intro of game, some story...
function eventIntro()
txt("You have always wanted to help the world, change it for the better. But before making changes at such a huge scale, you need to scale up from the bottom, as they say, charity begins at home. You have decided to start by helping the people around you, then someday the world.",14)
end
--code for drawing something special on intro screen
function eventLogo()
print("By R",20,10,2,true,2,false)
end
--describe rooms here, r=current room
function eventDescribe(r)
if r==1 then
txt "This is your room, dimly lit in the evening with christmas lights. You like the lights. There is some 90's music playing on a stereo, you like the music. There is an atlas on a table, you were reading it."
elseif r==2 then
txt "This is your balcony. You will probably miss the balcony when you leave the place. There is a tree surrounded by an apartment complex. You stand there for a second, with the evening wind rushing into your face"
elseif r==3 then
txt "This is the kitchen. It's functional. You can't film it for a TV show though. But there's fish in the fridge."
elseif r==4 then
txt "This is a corridor. Your bathroom is ahead."
elseif r==5 then
txt "This is your bathroom. There is no water running right now. But there's a soap you can use for a shower when water shows up."
elseif r==6 then
txt "This is another corridor."
elseif r==7 then
txt "Lory is a friend of yours. He is sitting in his dimly lit room. Guess he likes it that way too. He is trying to write a love letter for his girlfriend, but seems to have discarded the idea since he can't decide what to call her in the letter. The letter is lying on a table."
elseif r==8 then
txt "The corridor ends here to another of your neighbours door. There is a dog playing with his ball here. You forgot the dog's name. He was very sociable as a puppy but now barks at everyone, until someone points a camera at him. Drama Queen. Perhaps scared."
elseif r==9 then
txt "This is another corridor that end with at the stairs. You can see the train tracks from here."
elseif r==10 then
txt "You are on the street. There is a person taking a shower on a public tap. I guess it's for watering plants, but there are no plants here, only one tree, needs no watering. He looks upset for some reason."
elseif r==11 then
txt "You are at the school grounds."
elseif r==12 then
txt "There is a woman sitting on a bench. She looks curious yet upset. Perhaps she's thinking about something."
elseif r==13 then
txt "This is a park. Your friends are hanging out here. You ask them to call you when they go to the park to play, but they never do. They look upset for some reason."
elseif r==14 then
txt "You are at the train station. You see a board with the train timings. You can take one right now. Ofcourse you will need a ticket."
elseif r==15 then
txt "This is the ticket counter. An old lady is sitting here knitting a sweater. You have to talk to her if you want to get the ticket."
end
end
--describe objects here, i=object index
function eventExamine(i)
if i==1 then
txt "This is a book that features maps from different countries and of the whole world. It also features the history of the formation of earth and about the formation of the continents."
elseif i==2 then
txt "Fish is the primary diet in most parts of the world, not in your home though, some friend is using your refrigerator."
elseif i==3 then
txt "It feels much better to soap up during a shower, it feels cleaner. Even ancient societies used some form of soap. But some soaps have harmful chemicals."
elseif i==4 then
txt "Who could've invented it? From humans to animals, even birds play with balls. It's a naturally occuring shape, perhaps nature was coded with an inbuilt video game."
elseif i==5 then
txt "Dear ___, If I could tell you how much I appreciate the time we spend together, then I would have told you so. But I can't, so I shan't."
elseif i==6 then
txt "Cash runs the whole world. Someday it might take different forms, much better than bartering though."
elseif i==7 then
txt "A train ticket, show this to a ticket collector and you somewhat increase your chances to not lose your train seat."
elseif i==8 then
txt "A train. A big train. With a blue engine. And a happy smile. Sometimes I pretend inanimate objects are people because their design resembles a face."
elseif i==9 then
txt "An oakwood table."
elseif i==10 then
txt "He smells of onions."
elseif i==11 then
txt "He seems happy."
elseif i==12 then
txt "She seems really deeply concerned with her thoughts."
elseif i==13 then
txt "The best friends a man can get."
elseif i==14 then
txt "She seems too old to still be working."
elseif i==15 then
txt "Your classmate, often refers to you as her bestie for god knows why. She's shouting at a bunch of street vendors."
end
end
--ret 1 for allowing take action, i=object index
function eventBeforeTake(i)
if i==9 then
txd "You can't carry the table around that easily, it's too heavy."
elseif i==10 or i==11 or i==12 or i==13 or i==14 or i==15 then
txt "They probably wouldn't want to be carried around right now."
else
return 1
end
end
--action after taking object to inventory, i=object index
function eventAfterTake(i)
if i==9 then
txi "Not that heavy actually."
end
end
--ret 1 for allowing drop action, i=object index
function eventBeforeDrop(i)
if i==2 then
txd "Dropping fish could become an internet trend someday."
elseif i==3 then
txt "Careful! Someone might fall. You might fall."
else
return 1
end
end
--messages after droping object to room, i=object index
function eventAfterDrop(i)
if i==4 then
txd "It bounces back into your hand ... oops you couldn't catch it though."
elseif i==5 then
txt "The floor was wet, all the ink on the letter has vanished. It is useless now."
gobjr(5,VOID)
end
end
--ret 1 when failed to use object, i=object index
function eventUse(i)
if i==1 and room==12 then
txi "The lady on the bench screams with joy"
txt "Oh my god, this is exactly what I needed. This even has the evidence. Not only earth but every planet is flat, infact our whole solar system is flat, how else could they show it in a book which is flat! I can now prove to the whole world that the world they have been living in is indeed flat."
txt "This conversation confuses you."
txt "Listen, she says, you look so confused about everything, if life confuses you, you gotta talk to the old lady by the ticket counter. She's very nice, and wise."
sobjr(1,VOID)
points=points +1
elseif i==1 and room==7 then
txi "I already have the book dude, don't give it to me."
elseif i==1 and room==8 then
txi "The dog tears up the book."
sobjr(1,VOID)
elseif i==1 and room==10 then
txi "You give the book to the man who then proceeds to read it while his hands were wet, the books literally melts before he could read the first paragraph of the first page."
sobjr(1,VOID)
elseif i==1 and room==13 then
txi "I don't read books you nerd! shouts your best friend."
elseif i==1 and room==11 then
txi "This is not a good time for me to read this, says the frog."
elseif i==1 and room==15 then
txi "I am too old to benefit from reading this, says the old lady, I also never really liked reading in general."
elseif i==2 and room==8 then
txt "The dog looks curiously at you, then at the fish, then it grabs the fish from you hand and starts chomping on it."
txt "The ball she was playing with rolls towards your feet."
txt "DO DOGS EVEN EAT FISH? You ask yourself"
txt "You now have the ball the dog was playing with."
sobjr(4,INV)
sobjr(2,VOID)
elseif i==2 and room==11 then
txt "The frog disregards your offer of a fish."
elseif i==2 and room==15 then
txt "The old lady says she stopped eating fish ever since she saw a movie about a lost fish."
elseif i==2 and room==12 then
txt "It's not even cooked, take it away, says the lady at the bench."
elseif i==3 and room==7 then
txt "You soap up Lory, but there's no water anywhere, he is looking annoyed. You don't have a bucket to bring water from downstairs. Lory cleans himself with a towel."
elseif i==5 and room==12 then
txt "I don't even know you to be honest, says the lady at the bench."
elseif i==5 and room==15 then
txt "You are just not my type, says the old lady."
elseif i==5 and room==8 then
txt "The dog tears up the love letter."
sobjr(5,VOID)
elseif i==6 and room==8 then
txt "The dog grabs your cash and asks you to stop bothering her anymore."
sobjr(6,VOID)
elseif i==3 and room==10 then
txt "The man happily takes the soap from you and rubs it over his body."
txt "The man acts so thankful, it almost as if you brought joy to his whole life."
sobjr(3,VOID)
points=points+1
elseif i==4 and room==13 then
txt "Your friends look happy as ever. They immediately start throwing it around. One of your friend takes out some money from his pocket and gives it to you."
txt "You now have some cash to pay for whatever you might want to buy."
sobjr(4,VOID)
sobjr(6,INV)
points=points+1
elseif i==5 and room==11 then
txt "The giant frog takes the letter from you, reads it and turns into a soft spoken human girl."
txt "She asks you to not call her a frog the next time you meet with her."
txt "She rushes away."
txt "The people she was screaming at thank you for your bravery."
sobjr(5,VOID)
sobjr(15,VOID)
points=points+4
elseif i==6 and room==15 then
txt "The old lady gives you a train ticket."
txt "Go wherever you want to go, she says. It's a one day pass. But remember, you can only go so far without a foal"
txt "A goal? you ask."
txt "Do you not know what a foal means? I grew up in a ranch, I miss them so much."
sobjr(6,VOID)
sobjr(7,INV)
elseif i==7 and room==14 then
txt "You have now taken the train. But you have to drive it yourself."
sobjr(8,INV)
elseif i==8 and room==14 then
txt "You can now go roam around the world, or in practical terms your own city. Lots of people need help for things they just can't arrange for themselves. And believe it or not, you have been helping people all this time to reach this end. If not then perhaps you should figure out how to use all the other objects in the simulation ...aagh hmmm ... game."
txt "A journey isn't always about the destination, but the people you meet on the way."
txt "And I hope you enjoyed this journey."
txt "The End."
win()
else
return 1
end
end
--ret 1 when failed to open object, i=object index
function eventOpen(i)
if i==5 and i==7 then
eventExamine(i) --you even can call function to not repeat the same code as in examine
elseif i==1 then
txt "Your flip through the pages of your favourite book of all time."
elseif i==10 then
txt "This is not a slasher movie."
elseif i==11 then
txt "He already seems pretty open."
elseif i==12 then
txt "You perv."
elseif i==13 then
txt "They refuse to open up to you, perhaps such an emotional connection is just not there."
elseif i==14 then
txt "Don't!"
elseif i==15 then
txt "This isn't really a dissection class."
else
return 1
end
end
--ret 1 when failed to push object, i=object index
function eventPush(i)
if i==2 then
txd "You tried to push the fish but it looked very odd!"
elseif i==8 then
txd "The train won't move."
elseif i==10 then
txd "You can only push a man so far."
elseif i==11 then
txd "This place is too slippery, please don't do it."
elseif i==12 then
txd "Is this a hobby of yours?"
elseif i==14 then
txd "She is sitting behind a counter and hence cannot be pushed."
elseif i==15 then
txd "The frog stares at you for a moment and asks you whats wrong with you. Pushing her again leads to nothing."
else
return 1
end
end
--ret 1 when failed to talk with object, i=object index
function eventTalk(i)
if i==2 then
txi "You talk with the fish about how confused you feel about the world around you."
elseif i==7 or i==8 then
txi "Yes, this might take you to where you think your destination is."
elseif i==10 then
txi "I am very old school, Lorry tells you."
elseif i==11 then
txi "Even the simplest of things can bring so much joy."
elseif i==12 then
txi "We are going to have the first debate in the society that I run, good arguements with evidence and I will show it to the world."
elseif i==13 then
txi "Go away loser."
elseif i==14 then
txi "Give a man a ticket and he will travel for a day, teach a man to tick it and he will randomly answer his SAT questions."
elseif i==15 then
txi "Can you please not call me a frog!"
else
return 1
end
end
--what happens when player tries to move from old room to new room
--ret 1 if move is allowed
function eventBeforeMove(ro,rn)
if ro==2 and rn==3 then
txd("You are not allowed to move from room "..ro.." to room "..rn)
else
return 1
end
end
--what happens when player moves from old room to new room
function eventAfterMove(ro,rn)
-- txi("You moved from room "..ro.." to room "..rn)
end
--what happens when player waits
function eventWait()
if room==1 then
txt("One of the lights flickered for a second.",1)
elseif room==2 then
txt("Someone is cooking fish somewhere, you can smell it.")
elseif room==8 then
txt("The dog barks at you.")
elseif room==7 then
txt("Lory stares at you.")