-
Notifications
You must be signed in to change notification settings - Fork 0
/
terra-real.p8
2473 lines (2107 loc) · 92.1 KB
/
terra-real.p8
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
pico-8 cartridge // http://www.pico-8.com
version 39
__lua__
--terra - a terraria demake
--by cubee 🐱
cartdata"cubee_terra"
function _init()
for i=-32768,0x55ff do
poke(i)
end
_reload()tospr("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee9eeeeee8aeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaeeeeeeae9eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee88eae88eee9a8eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee88aa988a9a9a9aa9aeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8a9aaaaaaaaa9aaaaaaaeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee9a229aa929929929a98eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8aa233294444443339aaeeeeeeee89eeeeeeeeeeeae9eeeeeeeeeeeaaeeeeeeeea944343444433342aa988eeeeeeeaee9e9eeeeee9aeeeeeeeeeeee9e9eeeeee8a9333343333333339aaaeea8eeee9e8e9eeeeeee898ee8eeeeaeee8eaeeeeee8a233333343332232aaa889e8ee8a99a8a898e88a89aea988ee89e88899eeeeeea92929243329aa99aaaa9a9988ea9a9aaaa999a9a9aaaaa8e8eae89a9a9aeeee8aaa9a934439aaaaaaaaaaa9aa9a9aa999aaaaaaaaa999aaa9888a999aa88eeee9aaaa243639aaaa996119aaaaa92222439aaaa929226b9aaaa9a934229a9eeeeeaaaa23762aaaa91777b79aaa9343344432aa9343344771aaaa93444429a8eeee8aa9336139aa96b7617769aa93443233439a93443333679aaa23223432a9eeeeaaaa267139aa97769a9661aa23432992342a24332923161aa933aa9342a98eee8aa936732aa96b19aaa1329a93349aa9333993439aa93169aa22aaa243999eeee9aa371339aa1771111743aa93439aa9239a94339aa9239aaaaaaa9233998eee8a9a2673399ab16b671622aa93349aaaaaaa93439aaaaaaaa999992333998eeee9a936b32aa9776199a99aaaa2332aaaaaaa93332aaaaaaaa233334332a9eeeee8aa21732aa93449aaaaaaaa93432aaaaaaa933329aaaaaa93333333339a9eeee9a933139aaa93329a99329aa2339aaaaaaaa2339aaa9aa92339aa9332a98eeee892333329aaa2433223329a933329aa9aaa933329a9aaaa2333223333a9eeeee8a933339aaaa93333332aaa93339aaaaaaa93339aaa9aaa992233333399eeeee99233339a9a9a923232aaaa93229a9999a993229a9a99a99aaa922333999eeee8a29929a98889aa9a9aa99aa99a998e8e98a99aa9898998e989aa9992a98eeeee899aa998eeee99aaaa88e899899eeeeeee99898eeeeeeeeee889a9aaa98eeeeee8998eeeeeeeee8e8eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee899a98eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",64,64,0)
t,mouse,mute,cam_x,cam_y,actx,acty,bosshp,
env,spawns,bgs,around,
stats,
palettes,
recipes,
toolstat,
drops=
0,dget(0)==1,dget(1)==1,0,0,0,0,0,
{__index=_ENV},{},split"0,0,16,16,16",split"-1,0,1,0,0,-1,0,1,-1,-1,1,-1,-1,1,1,1",
split[[gslime|10|14|6|0|59:1|slime|0.8|1|0|0|176|0|1|1
,bslime|13|25|8|2|59:2|slime|1|1|0|0|144|0|1|1|12:13:7|0|0.875
,rslime|1|42|15|4|59:2_20:1|slime|1|1|1|0|144|0|1|1|0:1:6|0|0.875
,yslime|4|42|16|7|59:3_21:1|slime|1|1|1|0|144|0|1|1|3:4:5
,jslime|10|50|18|6|59:4|slime|1|1|1|0|144|0|1|1|9:10:5
,jspike|10|40|20|8|60:1_59:-4|slime|1|1|1|0|195|0|1|1|9:10:5:2:3
,eye|15|55|18|2|54:1|eye|0.8|1|0|1| 1.5|10.5|1|1|13:2:0:15
,caye|15|60|18|4|54:1|eye|0.7|1|0|1|1.5|10.5|1|1|6:2:7:15
,grye|9|55|20|0|54:1|eye|0.8|1|0|1|1.5|10.5|1|1|13:8:0:9
,zombie|9|40|14|6|59:3|fighter|0.5|0.3|0|0|146|0|1|1|0:2:3:1:6
,twigie|9|40|16|4|59:3|fighter|0.55|0.3|0|0|146|0|1|1|0:2:3:1:2:9
,femaie|9|32|12|3|59:3|fighter|0.6|0.3|0|0|146|0|1|1|2:2:3:1:15:3
,baldie|9|36|15|5|59:3|fighter|0.5|0.3|0|0|146|0|1|1|2:2:3:1:6:15
,eater|8|38|24|8|61:1_____________________________________________________________________________________________99:1|flying|0.5|1|0|1|1.5|12.5|1|1|1|0|1.4
,bat|13|15|13|2|86:1|flying|0.8|1|0|0| 162|0|1|1|12:13:5
,jbat|2|30|20|4|89:1|flying|0.8|1|0|0| 162|0|1|1|1:2:4
,hornet|3|46|26|12|60:1|flying|0.5|1.5|1|0|166|0|1|1
,honeyt|4|42|28|12|60:1|flying|0.6|1.5|1|0|166|0|1|1|4:5:2:3:4
,leafyt|9|38|30|14|60:1|flying|0.6|1.5|1|0|166|0|1|1|3:4:8:9:10
,skeleton|7|40|20|8|52:3_52:5_56:1|fighter|0.6|0.4|0|0|182|0|1|1|1:2:3:12:1
,pantston|7|40|22|8|52:3_52:5_56:1|fighter|0.6|0.4|0|0|182|0|1|1|1:2:3:2:6
,headacon|7|44|20|12|52:3_52:5_56:1|fighter|0.6|0.4|0|0|182|0|1|1|8:3:4:9:1
,cohbeetle|15|40|20|10|93:-1|fighter|1|0.5|0|0|164|0|1|1|1:15:15:3:2
,lacbeetle|15|40|20|10|93:-1|fighter|1|0.5|0|0|164|0|1|1|2:15:3:1:0
,cyabeetle|13|40|20|10|93:-1_20:2|fighter|1|0.5|0|0|164|0|1|1|12:13:13:1:0
,eocservant|15|8|12|0|0:1|flying|1|0.6|0|1|1.5|14.5|1|1
,marcoservant|2|20|16|0|0:1|flying|1|0.9|0|1|1.5|16.5|1|1
,tentacle|10|200|22|10|0:1||0|1|0|1|1.5|22.5|1|1|8:9:3:4:5:9:10:8:9:10:11:12:13:14:10
,eoc|15|2400|14|12|23:-18|eoc|0|1|0|1|19.5|22.5|3|3|1|1200|1.1
,kingslime|13|1800|22|10|20:-7_21:-7_22:-7|slime|0|1|1|0|230|0|3|2
,marco|1|3700|28|13|98:-1_55:-6|eoc|0|1|0|1|36|23|4|4|1|2100|1.4
,plantera|10|4200|40|16|90:5||0|1|0|1|27.5|22.5|3|3
,seed|10|1|25|0||projectile|0|1|1|1|1.5|18.5|1|1
,marcolaser|10|1|16|0||projectile|0|1.8|1|1|1.5|20.5|1|1|12:13
,stinger|10|1|13|0||projectile|0|0.7|1|1|1.5|24.5|1|1|0:0:0:0:0:2:3
]],
split([[
130,132,4,
9,10,5,134,
131,3,139,7,
1,140,12,136,128;
128,130,132,
4,137,133,5,
1,131,3,6,
129,1,140,2,128;
0,128,130,
132,4,130,133,
129,1,131,13,
0,129,1,130,0;
0,0,128,
128,132,128,130,
0,129,1,5,
0,0,129,128,0;
0,0,0,
0,128,0,128,
0,0,129,130,
0,0,0,0,0;
]],";"),
split([[
17:3|5,59;
68:1|17:3,5:4;
14:2|5;
5|14:2;
78:1:15|5:6;
13:1:16|3:2;
64:1:16|19:2;
70:1:16|21,3;
75:1:15|5:5;
87:1:15|86:2,93;
87:2:4|9:3;
103:1:4|96:1,55:2,98;
96:1:18|89:10,55:2;
74:1:4|55:1,61:2,52:99;
107:100:4|52:100,98:1;
105:30:18|52:30,58:2;
80:15|17:1,52:15;
52:25:15|3:1,5:1;
73:1:4|55:1,61:2,51:99;
106:50:18|51:50,55:1;
106:50:18|81:50,55:1;
81:20:18|57:1;
51:25:18|56:1;
92:1:4|57:2,59:99;
15|5:10;
16:1:15|5:4,3:10,17:3;
18:1:15|56:5;
4:1:18|58:4,98:1;
91:1:4|53,90:4;
65:1:4|85,90:4;
104:1:4|58:3,89:3,98:1;
53:1:4|24,84,34;
8:1:4|72,55:2;
94:1:4|93:5,95;
102:1:4|60:10,89:8;
84:1:18|60:10,89:8;
85:1:18|50,55:2;
95:1:18|48,55:1;
101:1:18|55:4,61:6;
55:1:16|23:3;
24:1:18|55:3;
26:1:18|55:4;
72:1:15|17:4,5:6;
100:1:18|58:7;
58:1:16|22:4;
34:1:18|58:2;
28:1:18|58:3;
33:1:18|58:3,5:4;
35:1:18|58:2,5:3;
32:1:18|58:2,5:3;
57:1:16|21:4;
38:1:18|57:2;
29:1:18|57:3;
37:1:18|57:3,5:4;
39:1:18|57:2,5:3;
36:1:18|57:2,5:3;
56:1:16|20:3;
42:1:18|56:2;
30:1:18|56:3;
41:1:18|56:3,5:3;
43:1:18|56:2,5:3;
40:1:18|56:2,5:3;
46:1:15|5:2;
31:1:15|5:3;
45:1:15|5:3;
47:1:15|5:3;
44:1:15|5:3;
69:4:15|5;
66:4:15|2;
67:4:15|3;
71:4:15|7;
76:4:15|12;
5:1:15|69:4;
2:1:15|66:4;
3:1:15|67:4;
7:1:15|71:4;
12:1:15|76:4;
1:4|2:4,89;
6:4|7:4,89;
10:4|2:4,61;
62:1:15|54:6;
63:1:18|59:15;
25:1:18|61:6,55:1;
88:1:4|89:6;
108:1:75|90:6,9:1,56:2,58:1;
77:1:4|90,55,61:8;
48:1:4|90:2,28,61:2;
49:1:4|90:2,56:2,54:2;
50:1:4|90:2,56:3;
9:1:4|90,87;
87:1:4|90,9;
3:20:4|90,12:20;
12:20:4|90,3:20;
99:1:4|90:2,24
]],";"),
split[[
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
12:ranged:12:gel:1:1.3,
20:hpup:1:1,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
20:melee:20,
0:summon:16:marco-22,
9:pick:15:2.4:0:1.1,
0:block,
11:ranged:26:arrow,
9:ranged:27:arrow,
8:ranged:28:arrow,
4:ranged:30:arrow,
9:hammer:28:5:0:1.1,
6:pick:17:1.8:0:1.1,
13:melee:20:1.1:0:1.1,
7:axe:26:1.8:0:1.1,
9:hammer:29:4,
6:pick:19:1.3,
11:melee:21,
6:axe:26:1.3,
7:hammer:30:4,
5:pick:20:1.1,
10:melee:21,
5:axe:27:1.1,
2:hammer:37:3,
4:pick:23,
7:melee:25,
3:axe:30,
8:ranged:20:arrow:0:1.1,
0:mirror,
24:ranged:48:bullet:0:1.2,
7:bullet:8:220,
4:arrow:3.5:52,
42:melee:21:1.15:1:1.2,
0,0,0,0,0,
0:gel:3:123:0:2,
0,0,
0:summon:16:eoc-53,
0:summon:16:kingslime-0,
0:block,
22:ranged:10:bullet:1,
0:block,
0:block,
0:block,
0:block,
0:block,
0:block,
6:ranged:26:gel,
8:bullet:8:220,
6:arrow:3.5:52,
0:block,
0:block,
0:block,
0:block,
100:pick:8:100,
7:arrow:4:80,
9:bullet:9:220,
0,0,
28:melee:30:1.3:0:1.3,
5:ranged:10:bullet:1:1.1,
15:hpup:60,
50:hpup:140,
0:summon:16:plantera-31,
0,0,
60:melee:18:1.2:1:1.4,
0:gel:4.5:123:0:3,
0,
22:ranged:18:arrow:1:1.1,
14:ranged:25:arrow:1,
0:boot:16:1.3,
0,
0,
22:melee:23:1.1:0:1.2,
5:armour,
8:armour,
13:armour,
0:boot:16:1.5:0:1.2,
13:melee:12:2:1:1.2,
18:arrow:3.2:105,
8:bullet:11:220:0:2,
14:arrow:4.5:107:0:2,
0:saturn,
]],
split[[
2,
2,
3,
4,
5,
7,
7,
8,
9,
2,
2
]]
pjump,pair,pdigt,pfall,pdiet,pswing,pangle,
mobs,lights,projectiles,craftable,items,parts,
invsel,invside,craftsel,
mode,nextmusic,currentmusic,worldmusic,
swingitem,drops[79],drops[82],drops[83],tilenames
=
true,true,0,0,0,0,0,
{},{},{},{},{},{},
1,1,1,
1,0,-1,0,
{id=0,usetime=10},78,5,5,
split([[forest grass
dirt
stone
cursed forge
wood
jungle grass
mud
flamethrower
life crystal
corrupt grass
ebonstone
grey brick
wooden platform
workbench
furnace
torch
anvil
clay
iron ore
silver ore
gold ore
demonite ore
light's bane
sigil of blight
nightmare pickaxe
sapling
gold bow
silver bow
iron bow
wood bow
gold hammer
gold pickaxe
gold broadsword
gold axe
silver hammer
silver pickaxe
silver broadsword
silver axe
iron hammer
iron pickaxe
iron broadsword
iron axe
wooden hammer
wooden pickaxe
wooden broadsword
wooden axe
shade bow
magic mirror
musket
musket ball
wood arrow
night's edge
lens
demonite bar
iron bar
silver bar
gold bar
gel
stinger
rotten chunk
suspicious-looking eye
slime crown
red brick
cubee's dogblaster
dirt wall
stone wall
campfire
wood wall
polished silver brick
jungle wall
wand of sparking
endless musket pouch
endless quiver
table
ebonstone wall
shadow orb
wooden door
the landshearer
flaming arrow
silver bullet
blade of grass
minishark
mushroom
healing potion
suspicious bulb
leafy seed
shimmering seed
terra blade
endless gel booster
beetle husk
beetle bow
demonite repeater
hermes boots
soul of blight
tentacle spike
gold armour
shadow armour
jungle armour
wasteland treads
goldery blattery
golden arrow
demonite bullet
blighted arrow
leinfors' hair protector
]],"\n")
generate()
loadplayer"100,100|46:1,45:1,47:1"
spawnplayer()
for k,i in next,recipes do
local r=split(i,"|")
recipes[k]={split(r[1],":"),split(r[2])}
for j,o in next,recipes[k][2] do
recipes[k][2][j]=split(o,":")
end
end
if stat(6)~="" then
loadplayer(stat(6))
mode=2
end
music"0"
poke(0x5f36,16)
poke(0x5f5a,255)
end
function _update60()
menuitem(5,mute and "music: off" or "music: on",function()mute=not mute dset(1,mute and 1 or 0) end)
poke(0x5f5c,invopen and 0 or -1)
poke(0x5f2d,mode<3 and 1 or 0x3)
msx,msy,jb,ab,rbp,pgfx,invkey,pinvkey,pdef,jk,saturn=stat(32),stat(33),mouse and invopen and 5 or 4,mouse and invopen and 4 or 5,btnp(1),pgfx or "",btnp(6) or stat(28,8),invkey,0,btn(jb)or stat(28,44)
while stat(30) do
if(stat(31)=="コ")p=stat(4)
end
smolmap()
if mode<3 then
if stat(120) or p then
if mode==2 then
for i=0,p and 32767 or serial(0x800,0x8000,32767) do
poke(0x8000+i,(p and ord(p[i+1]) or @(0x8000+i))-32)
end
spawnplayer(php)
else
if not p then
p=""
serial(0x800,0x4300,4864)
for i=0,4864 do
p..=chr(@(0x4300+i))
end
end
loadplayer(p)
end
loadedfile=true
end
if(btnp(5))load"#terra_char_edit"
if btnp(4) or loadedfile then
mode+=1
loadedfile,p=ssfx"7,0"
end
if mode>2 then
_reload()
end
else
menuitem(4,mouse and "mouse: on" or "mouse: off",function()mouse=not mouse dset(0,mouse and 1 or 0) end)
lights,mx,jpow={},1,1
menuitem(1,"save",function()
sp,sw=php..","..php_max..","..phurt..","..orbsmash..","..worldtime.."|",""
genprint"processing player..."
for k,i in next,inventory do
sp..=i.id..":"..i.amount..(k<#inventory and "," or "|")
end
genprint"processing world..."
for i=0,32767 do
sw..=chr(@(i+0x8000)+32)
end
function a(s,s2)
printh(s,"@clip")
repeat
poke(0x5f30,1)
genprint(s2,"press pause to continue")
until btn(6)
end
a(sp..pgfx.."|","player copied to clipboard")
a(sw,"world copied to clipboard")
end)
bigmap()
-- inventory
for i in all(inventory) do
local _ENV,g=i,_ENV
local stats=
split(toolstat[id],":")
or split"0,item"
type=stats[2] or "item"
tool=type=="pick" or type=="axe" or type=="hammer"
damage,var,usetime,
amount,autoswing,
scale,melee=
stats[1],stats[4],stats[3] or 16,
amount or 1,stats[5]==1 or tool or type=="block",
stats[6]or 1,type=="melee" or tool
if(type=="boot")g.mx,g.jpow=max(mx,var),max(jpow,scale)
if(type=="armour")g.pdef=max(pdef,damage)
if(type=="saturn")g.saturn=true
knockback=type=="melee" and var or 1
del(inventory,amount<=0 and _ENV)
end
if invside==1 then
invsel=loop(invsel-stat(36),inventory)
else
craftsel=loop(craftsel-stat(36),craftable)
end
if invopen then
if(mouse)invside=msx\64
if invside>0 then
if(btnp(0) and #craftable>0)invside=0
if(btnp(2))invsel-=1
if(btnp(3))invsel+=1
invsel=loop(invsel,inventory)
-- trash
if btnp(ab) then
if hoveritem then
trashslot,hoveritem=hoveritem
else
hoveritem,trashslot=trashslot
end
updaterecipes()
-- hover
elseif btnp(jb) or invkey and not pinvkey and hoveritem then
if hoveritem then
hoveritem=add_inventory(hoveritem,max(invsel,1))
else
hoveritem=deli(inventory,invsel)
end
updaterecipes()
end
invsel=min(invsel,#inventory)
-- craft
else
if(rbp)invside=1
if(btnp(2))craftsel-=1
if(btnp(3))craftsel+=1
craftsel=loop(craftsel,craftable)
local recipe=craftable[craftsel]
if recipe then
local out,ing=unpack(recipe)
if btnp(jb) then
for i in all(ing) do
local missing=true
for _ENV in all(inventory) do
if(id==i[1] and amount>=(i[2] or 1))missing=false
end
if(missing and avail)avail=ssfx"9,0"
end
if avail then
for i in all(ing) do
for _ENV in all(inventory) do
if id==i[1] then
amount-=i[2] or 1
end
end
end
-- find out
local slot,ininv=1
for a in all(inventory) do
if a.id==out[1] then
ininv=true
end
if(not ininv)slot+=1
end
if ininv then
inventory[slot].amount+=out[2] or 1
else
add_inventory{id=out[1],amount=out[2] or 1}
end
ssfx"8,2"
end
end
if(pbtn4 and not btn(jb))updaterecipes()
pbtn4=btn(jb)
else
invside=1
end
end
pjump=true
else
tx,ty,invside,craftsel,frc,bossmusic
=rnd"320",rnd"47",1,1,pair and 0.03 or 0.08
if(mget(tx,ty)==27)tree(tx,ty+1)
worldtime+=0.4
worldtime%=24000
if pdead then
pdiet-=1
if pdiet<=0 and jk then
spawnplayer(max(php_max/2,100))
end
else
php+=t%100\99
local bl,br=btn(0) or stat(28,4),btn(1) or stat(28,7)
if bl then
if(pxv>-mx)pxv-=pxv>0 and 0.15 or 0.08
if(canturn)pflip=true
elseif br then
if(pxv<mx)pxv+=pxv<0 and 0.15 or 0.08
if(canturn)pflip=false
else
pxv-=sgn(pxv)*frc
if abs(pxv)<=frc then
pxv=0
end
end
pyv+=0.08
-- right
local d=0
repeat
local bx,by=(px+3+d)/8,py/8+0.375
local b,t=mget(bx,by),fmget(bx,py/8-0.375,0)
if fget(b,5) then
door(bx,by,b,1)
elseif pxv>0 and (t or fget(b,0)) then
pxv=0
px+=d
if(br and not t)pyv,jk=min(pyv,-1),true
break
end
d+=1
until d>pxv or e
-- left
d=0
repeat
local bx,by=(px-4+d)/8,py/8+0.375
local b,t=mget(bx,by),fmget(bx,py/8-0.375,0)
if fget(b,5) then
door(bx,by,b,-1)
elseif pxv<0 and (t or fget(b,0)) then
pxv=0
px+=d
if(bl and not t)pyv,jk=min(pyv,-1),true
break
end
d-=1
until d<pxv
px+=pxv
-- down
d,pair=0,true
repeat
local y=(py+4+d)/8
local l,r=mget(px/8-0.375,y),mget(px/8+0.25,y)
if pyv>0 and (fget(l,0) or fget(r,0) or (l==14 or r==14) and not (btn(3) or stat(28,22))) then
if(not jk)pjump=false
pyv,pair=0
py+=d
pfall=max(pfall/8-13)
if pfall>0 then
php-=pfall*10\1
piframes,pfall=30,0
sfx(0,-1,phurt,12)
end
if jk and not pjump then
pjump,pyv=true,-2.2*jpow
end
break
end
d+=1
until d>pyv
-- up
d=0
repeat
local y=(py-5+d)/8
local l,r=fmget(px/8-0.375,y,0),fmget(px/8+0.25,y,0)
if pyv<0 and (l or r) then
if l and r then
pyv=0
py+=d
end
if(not r)px+=1
if(not l)px-=1
break
end
d-=1
until d<pyv
if pjump and not jk then
pyv=max(pyv,-0.2)
end
py+=pyv
pfall+=pyv
digx,digy=pflip and -7 or 7,(btn(3) and 7) or (btn(2) and -7) or 0
if (btn(3) or btn(2)) and not (btn(0) or btn(1)) then
digx=0
end
actx,acty,helditem
=(mouse and cam_x+msx or px+digx)/8,(mouse and cam_y+msy or py+digy)/8,inventory[invsel] or {id=0,usetime=10}
tile,canturn,a8x,a8y,hitype,hiuse,hid,hivar,hiscale,digging
=mget(actx,acty),true,actx*8,acty*8,helditem.type,helditem.usetime,helditem.id,helditem.var,helditem.scale
local svar=split(hivar,"-")
if btn(ab) and (not helditem.tool or not mouse or dist(actx*8-px,acty*8-py)<32) then
if lastitem==helditem then
if not fget(hid,7) and pswing==0 and (btnp(ab) or helditem.autoswing) then
pswing,swingitem=hiuse,helditem
end
if hid==91 then
if(pdigt<=0)pdigt=hiuse*2sfx"3"add_projectile(px,py,pangle,2.5,35,97)
pdigt-=1
elseif helditem.tool then
if hitype=="axe" and tile==83 or hitype=="pick" and fget(tile,1) and mget(actx,acty-1)~=83 or hitype=="hammer" and fget(tile,2)then
digging=true
pdigt+=hivar or 1
if(pdigt%hiuse==1)sfx"4"
if pdigt>=hiuse*3 then
pdigt=0
break_tile(actx,acty,tile)
end
end
elseif hitype=="block" and pdigt%7==0 then
if not mouse and hid==14 and pxv~=0 then
acty+=1
end
local lt,tile,canplace=mget(actx,acty+1),mget(actx,acty)
local function c(i)
return fget(i,0) or fget(i,2) or i==14
end
for i=-1,1 do
if tile==0 and (c(mget(actx+i,acty)) or c(mget(actx,acty+i))) then
canplace=true
end
end
if(hid<82 and fget(hid,4))canplace=fget(lt,0) or lt==14
if canplace and hid~=tile and not fget(tile,0) and tile<83 then
if(tile>0)break_tile(actx,acty,tile)
sfx"4"
mset(actx,acty,hid)
helditem.amount-=1
end
elseif hitype=="ranged" and pswing==hiuse then
ammosprite,ammodamage=-1
for a in all(inventory) do
if a.type==hivar then
ammodamage=a.damage
if(not fget(a.id,1))a.amount-=1
add_projectile(px,py,pangle,a.usetime/2,helditem.damage+ammodamage,a.var,a.scale)
ssfx(hivar=="gel" and "9,1" or "7,3")
break
end
end
if not ammodamage then
pswing=0
ssfx"9,0"
end
elseif hitype=="hpup" and btnp(ab) and pswing==hiuse then
if php<php_max and not hivar or hivar and php_max<400 then
if(hivar)php_max+=helditem.damage
php+=helditem.damage
helditem.amount-=1
sfx"5"
end
elseif hitype=="summon" and (svar[1]~="marco" or timelight>1) and btnp(ab) and currentmusic==svar[2] then
sfx"10"
addmob(svar[1],px+80*sgn(rnd"-1"),py-40,true)
helditem.amount-=1
_reload()
if(svar[1]=="plantera")tospr("eeee92f212ffff212f29eeeeeaae8222122ff2212228eaae54991221222222221221994544e812212222222212218e44eef811212222222212118feeee1f1111122222211111f1eeeee2f12f11222211f21f2eeeeee11a81f111111f18911eeeeee9aa9a1211112199aaaeeeeeaa98aa99a99aa9aa89aaeeeee98aa99a9cc9a89aa89eeeeeee999889e8ce9ce9aaeeeeeeeee898ceec8ec8e98eeeeeeeeeeeee88e8eee8ceeeeeeeeeeeeee8cee8ceeceeeeeeeeeeeeeeee8eee8eeeeeeeeeee",24,72,112)
elseif hitype=="mirror" and btnp(ab) then
spawnplayer(php)
sfx"11"
end
end
elseif pswing==0 then
pdigt,lastitem=0,helditem
end
pswing,canturn=max(pswing-1),not (pswing>1 and (helditem.type=="melee" or helditem.type=="ranged"))
-- music
local floortile=mget(px/8,py/8+1)
if floortile>=1 and floortile<=3 then
worldmusic=py/8>47 and 12 or (worldtime<17500 and worldtime>4300 and 0 or 53)
else
worldmusic=tonum(split",,,,,31,31,,,22,22,22"[floortile]) or worldmusic
end
local a,d=(lastitem.usetime-pswing)/(lastitem.usetime*2)+0.1,4+4*hiscale
wxo,wyo=
cos(a)*(pflip and d or -d),
sin(a)*d
end
for _ENV in all(parts) do
yv=min(yv+0.07,3)
xv*=0.98
x+=xv
y+=yv
li-=1
if(li<0)del(parts,_ENV)
end
for i in all(items) do
local _ENV,g=i,_ENV
yv,timer=min(yv+0.04,1.2),max(timer-1)
xv*=0.95
if not pdead and timer<=0 and abs(px-x)<24 and abs(py-y)<24 then
xv+=(px-x)/50
yv+=(py-y)/50
if abs(px-x)<4 and abs(py-y)<4 then
if id==0 then
g.php+=20
else
local slot,ininv=1
for a in all(inventory) do
if a.id==id then
ininv=true
end
if(not ininv)slot+=1
end
if ininv then
g.inventory[slot].amount+=amount
else
add_inventory{id=id,amount=amount}
end
ssfx"7,2"
end
del(items,_ENV)
end
-- fall
else
local u,v=x/8,y/8
local gnd=mget(u,v+0.25)
if fget(gnd,0) or gnd==14 then
yv=min(yv)
end
if fmget(u,v-0.25,0) then
yv=max(yv)
end
if fmget(u,v,0) then
xv=0
end
end
x+=xv
y+=yv
del(items,#items>40 and i)
end
for _ENV in all(projectiles) do
if fget(bulletsprite,0) then
yv+=0.01
end
x+=xv
y+=yv