-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
1308 lines (1298 loc) · 54 KB
/
main.ts
File metadata and controls
1308 lines (1298 loc) · 54 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
namespace SpriteKind {
export const House = SpriteKind.create()
export const Decoration = SpriteKind.create()
export const TileCursor = SpriteKind.create()
}
function create_item_with_tooltip (name: string, image2: Image, description: string, tooltip: string) {
item = Inventory.create_item(name, image2, description)
item.set_text(ItemTextAttribute.Tooltip, tooltip)
return item
}
function get_stackable_item_count_name (name: string) {
item = get_stackable_item_name(name)
if (item) {
return parseFloat(item.get_text(ItemTextAttribute.Tooltip))
} else {
return [][0]
}
}
function do_action () {
if (tile_at_loc_is_one_of([the_cursor.tilemapLocation()], [
assets.tile`grass`,
sprites.castle.tileGrass1,
sprites.castle.tileGrass3,
sprites.castle.tileGrass2
]) && is_name_of_selected_item("Shovel")) {
tiles.setTileAt(the_cursor.tilemapLocation(), sprites.castle.tilePath5)
remove_decoration([the_cursor.tilemapLocation()])
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`stump`) && is_name_of_selected_item("Axe")) {
tiles.setTileAt(the_cursor.tilemapLocation(), sprites.castle.tilePath5)
tiles.setWallAt(the_cursor.tilemapLocation(), false)
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`wet_dirt`) && is_name_of_selected_item("Hoe")) {
tiles.setTileAt(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`)
} else if (tile_at_loc_is_one_of([the_cursor.tilemapLocation()], [sprites.castle.rock0, sprites.castle.rock1]) && is_name_of_selected_item("Pickaxe")) {
tiles.setTileAt(the_cursor.tilemapLocation(), sprites.castle.tilePath5)
tiles.setWallAt(the_cursor.tilemapLocation(), false)
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`water`) && is_name_of_selected_item("Watering can") && get_watering_can_fill() < 100) {
change_watering_can_fill(1)
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), sprites.castle.tilePath5) && is_name_of_selected_item("Watering can") && get_watering_can_fill() >= 10) {
tiles.setTileAt(the_cursor.tilemapLocation(), assets.tile`wet_dirt`)
change_watering_can_fill(-10)
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`) && is_name_of_selected_item("Potato")) {
tiles.setTileAt(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt_with_potato_1`)
change_stackable_item_count(-1)
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`) && is_name_of_selected_item("Carrot seed")) {
tiles.setTileAt(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt_with_carrot_1`)
change_stackable_item_count(-1)
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`) && is_name_of_selected_item("Beetroot seed")) {
tiles.setTileAt(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt_with_beetroot_1`)
change_stackable_item_count(-1)
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`) && is_name_of_selected_item("Lettuce seed")) {
tiles.setTileAt(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt_with_lettuce_1`)
change_stackable_item_count(-1)
} else if (is_name_of_selected_item("Debug menu")) {
open_debug_menu()
} else if (tile_at_loc_is_one_of([the_cursor.tilemapLocation()], non_fully_grown) && is_name_of_selected_item("Hoe")) {
give_player_seed_of(tile_to_vegetable_name([the_cursor.tilemapLocation()]))
tiles.setTileAt(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`)
} else if (tile_at_loc_is_one_of([the_cursor.tilemapLocation()], fully_grown_tiles) && is_name_of_selected_item("Hoe")) {
for (let index = 0; index < randint(1, 2); index++) {
give_player_seed_of(tile_to_vegetable_name([the_cursor.tilemapLocation()]))
}
for (let index = 0; index < randint(2, 4); index++) {
give_player_crop_of(tile_to_vegetable_name([the_cursor.tilemapLocation()]))
}
tiles.setTileAt(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`)
}
}
function tile_to_vegetable_name (loc_in_list: any[]) {
for (let tile of potato_stages) {
if (tiles.tileAtLocationEquals(loc_in_list[0], tile)) {
return "potato"
}
}
for (let tile of carrot_stages) {
if (tiles.tileAtLocationEquals(loc_in_list[0], tile)) {
return "carrot"
}
}
for (let tile of beetroot_stages) {
if (tiles.tileAtLocationEquals(loc_in_list[0], tile)) {
return "beetroot"
}
}
for (let tile of lettuce_stages) {
if (tiles.tileAtLocationEquals(loc_in_list[0], tile)) {
return "lettuce"
}
}
return "unknown"
}
function tick_time () {
tick_plant(potato_stages, potato_next_stage_chance)
tick_plant(carrot_stages, carrot_next_stage_chance)
tick_plant(beetroot_stages, beetroot_next_stage_chance)
tick_plant(lettuce_stages, lettuce_next_stage_chance)
for (let index = 0; index <= degradation_path.length - 2; index++) {
for (let location of tiles.getTilesByType(degradation_path[degradation_path.length - 2 - index])) {
if (Math.percentChance(degradation_chances[degradation_path.length - 2 - index])) {
tiles.setTileAt(location, degradation_path[degradation_path.length - 1 - index])
}
}
}
}
controller.up.onEvent(ControllerButtonEvent.Pressed, function () {
if (in_inventory) {
move_up_in_inventory_toolbar()
}
})
function update_tile_cursor_and_action_label () {
if (characterAnimations.matchesRule(the_player, characterAnimations.rule(Predicate.FacingUp))) {
tiles.placeOnTile(the_cursor, the_player.tilemapLocation().getNeighboringLocation(CollisionDirection.Top))
} else if (characterAnimations.matchesRule(the_player, characterAnimations.rule(Predicate.FacingRight))) {
tiles.placeOnTile(the_cursor, the_player.tilemapLocation().getNeighboringLocation(CollisionDirection.Right))
} else if (characterAnimations.matchesRule(the_player, characterAnimations.rule(Predicate.FacingDown))) {
tiles.placeOnTile(the_cursor, the_player.tilemapLocation().getNeighboringLocation(CollisionDirection.Bottom))
} else {
tiles.placeOnTile(the_cursor, the_player.tilemapLocation().getNeighboringLocation(CollisionDirection.Left))
}
the_cursor.setFlag(SpriteFlag.Invisible, !(have_something_selected_in_toolbar()) || is_name_of_selected_item("Debug menu"))
can_use = update_action_label()
if (can_last_use != can_use) {
can_last_use = can_use
if (can_use) {
animation.runImageAnimation(
the_cursor,
assets.animation`tile_cursor_animation_can_do`,
500,
true
)
} else {
animation.runImageAnimation(
the_cursor,
assets.animation`tile_cursor_animation`,
500,
true
)
}
}
}
function is_name_of_selected_item (name: string) {
if (have_something_selected_in_toolbar()) {
return toolbar.get_items()[toolbar.get_number(ToolbarNumberAttribute.SelectedIndex)].get_text(ItemTextAttribute.Name) == name
} else {
return false
}
}
function make_time_label () {
if (DEBUG_tilemap || DEBUG_menu) {
time_label = textsprite.create("8:00", 1, 2)
time_label.setBorder(1, 2, 1)
} else {
time_label = textsprite.create("8:00", 13, 12)
time_label.setBorder(1, 12, 1)
}
time_label.setFlag(SpriteFlag.RelativeToCamera, true)
time_label.z = 20
time_label.top = 4
last_time = game.runtime()
secs_left_in_day = 86400 - 8 * 3600
secs_elapsed_today = 0
day_of_the_week = 0
update_time()
}
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
if (in_inventory) {
handle_b_key_in_inventory_toolbar()
} else if (in_menu) {
} else {
handle_b_key_in_inventory_toolbar()
}
})
scene.onOverlapTile(SpriteKind.Player, assets.tile`house`, function (sprite, location) {
if (sprite.tileKindAt(TileDirection.Center, assets.tile`house`)) {
if (!(in_cutscene)) {
if (!(in_menu) && !(in_inventory)) {
open_action_menu()
}
}
}
})
function remove_item_from_toolbar (index: number) {
item = toolbar.get_items()[index]
if (!(item)) {
return [][0]
}
if (item.get_text(ItemTextAttribute.Tooltip) == "") {
if (toolbar.get_items().removeAt(index)) {
}
} else if (item.get_text(ItemTextAttribute.Tooltip) == "2") {
item.set_text(ItemTextAttribute.Tooltip, "")
} else {
item.set_text(ItemTextAttribute.Tooltip, convertToText(parseFloat(item.get_text(ItemTextAttribute.Tooltip)) - 1))
}
toolbar.update()
return Inventory.create_item(item.get_text(ItemTextAttribute.Name), item.get_image())
}
function make_tile_cursor_and_action_label () {
the_cursor = sprites.create(assets.image`tile_cursor`, SpriteKind.TileCursor)
the_cursor.setFlag(SpriteFlag.Ghost, true)
the_cursor.z = 20
action_label = textsprite.create("", 0, 15)
action_label.setFlag(SpriteFlag.RelativeToCamera, true)
action_label.bottom = scene.screenHeight() - 4
action_label.z = 20
can_last_use = true
update_tile_cursor_and_action_label()
}
controller.up.onEvent(ControllerButtonEvent.Repeated, function () {
if (in_inventory) {
move_up_in_inventory_toolbar()
}
})
function change_stackable_item_count (by: number) {
item = toolbar.get_items()[toolbar.get_number(ToolbarNumberAttribute.SelectedIndex)]
if (item.get_text(ItemTextAttribute.Tooltip) == "") {
item.set_text(ItemTextAttribute.Tooltip, "1")
}
item.set_text(ItemTextAttribute.Tooltip, "" + (parseFloat(item.get_text(ItemTextAttribute.Tooltip)) + by))
if (item.get_text(ItemTextAttribute.Tooltip) == "1") {
item.set_text(ItemTextAttribute.Tooltip, "")
} else if (item.get_text(ItemTextAttribute.Tooltip) == "0") {
toolbar.get_items().removeAt(toolbar.get_number(ToolbarNumberAttribute.SelectedIndex))
}
toolbar.update()
}
function get_stackable_item_name (name: string) {
for (let item of toolbar.get_items()) {
if (item.get_text(ItemTextAttribute.Name) == name) {
return item
}
}
for (let item of inventory.get_items()) {
if (item.get_text(ItemTextAttribute.Name) == name) {
return item
}
}
return [][0]
}
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
if (in_inventory) {
handle_a_key_in_inventory_toolbar()
} else if (in_menu) {
} else {
do_action()
}
})
function open_action_menu () {
enable_movement(false)
if (!(spriteutils.isDestroyed(menu_house))) {
menu_house.destroy()
}
in_menu = true
menu_house = miniMenu.createMenu(
miniMenu.createMenuItem("Close"),
miniMenu.createMenuItem("Sell from inventory...")
)
menu_house.setFlag(SpriteFlag.RelativeToCamera, true)
menu_house.top = 4
menu_house.left = 4
menu_house.z = 20
style_menu([menu_house], scene.screenWidth() - 8, scene.screenHeight() - 32, "Actions available")
menu_house.setButtonEventsEnabled(false)
menu_house.onButtonPressed(controller.A, function (selection, selectedIndex) {
if (selectedIndex == 0) {
menu_house.destroy()
enable_movement(true)
in_menu = false
the_player.y += 16
} else if (selectedIndex == 1) {
menu_house.destroy()
open_sell_menu()
}
})
menu_house.onButtonPressed(controller.B, function (selection, selectedIndex) {
menu_house.destroy()
enable_movement(true)
in_menu = false
the_player.y += 16
})
timer.background(function () {
while (controller.A.isPressed()) {
pause(0)
}
menu_house.setButtonEventsEnabled(true)
})
}
function animate_sprite (sprite: Sprite, _static: Image, static_condition: number, animation2: any[], animation_condition: number) {
characterAnimations.loopFrames(
sprite,
animation2,
100,
animation_condition
)
characterAnimations.runFrames(
sprite,
[_static],
0,
static_condition
)
}
function give_player_seed_of (name: string) {
if (name == "potato") {
add_item([Inventory.create_item("Potato", assets.image`potato`, "0.25,sellable,")])
} else if (name == "carrot") {
add_item([Inventory.create_item("Carrot seed", assets.image`carrot_seed`, "0.1,sellable,")])
} else if (name == "beetroot") {
add_item([Inventory.create_item("Beetroot seed", assets.image`beetroot_seed`, "0.15,sellable,")])
} else if (name == "lettuce") {
add_item([Inventory.create_item("Lettuce seed", assets.image`lettuce_seed`, "0.2,sellable,")])
}
}
function make_money_label () {
if (DEBUG_tilemap || DEBUG_menu) {
money_label = textsprite.create("$0", 1, 2)
money_label.setBorder(1, 2, 1)
} else {
money_label = textsprite.create("$0", 13, 12)
money_label.setBorder(1, 12, 1)
}
money_label.setFlag(SpriteFlag.RelativeToCamera, true)
money_label.z = 20
money_label.top = 4
money_label.left = 4
}
function open_sell_menu () {
enable_movement(false)
if (!(spriteutils.isDestroyed(menu_sell))) {
menu_sell.destroy()
}
in_menu = true
menu_sell_options = [miniMenu.createMenuItem("Close")]
if (menu_sell_selections.length == 0) {
menu_sell_selections = []
menu_sell_selections_max = []
for (let index = 0; index <= inventory.get_items().length - 1; index++) {
item = inventory.get_items()[index]
description = item.get_text(ItemTextAttribute.Description)
if (!(description)) {
continue;
}
if (item.get_text(ItemTextAttribute.Description).includes("sellable")) {
menu_sell_selections.push(0)
if (item.get_text(ItemTextAttribute.Tooltip) == "") {
menu_sell_selections_max.push(1)
} else {
menu_sell_selections_max.push(parseFloat(item.get_text(ItemTextAttribute.Tooltip)))
}
}
}
}
sell_price = 0
real_index = 0
for (let index = 0; index <= inventory.get_items().length - 1; index++) {
item = inventory.get_items()[index]
description = item.get_text(ItemTextAttribute.Description)
if (!(description)) {
continue;
}
if (item.get_text(ItemTextAttribute.Description).includes("sellable")) {
if (item.get_text(ItemTextAttribute.Tooltip) == "") {
menu_sell_options.push(miniMenu.createMenuItem("" + menu_sell_selections[real_index] + "/" + "1" + ": " + item.get_text(ItemTextAttribute.Name)))
} else {
menu_sell_options.push(miniMenu.createMenuItem("" + menu_sell_selections[real_index] + "/" + item.get_text(ItemTextAttribute.Tooltip) + ": " + item.get_text(ItemTextAttribute.Name)))
}
sell_price += menu_sell_selections[real_index] * parseFloat(item.get_text(ItemTextAttribute.Description))
real_index += 1
}
}
sell_price = Math.ceil(sell_price * 100) / 100
if (sell_price == 0) {
menu_sell_options.insertAt(1, miniMenu.createMenuItem("Sell for $0"))
} else if (sell_price * 100 % 10 == 0) {
menu_sell_options.insertAt(1, miniMenu.createMenuItem("Sell for $" + sell_price + "0"))
} else {
menu_sell_options.insertAt(1, miniMenu.createMenuItem("Sell for $" + sell_price))
}
menu_sell = miniMenu.createMenuFromArray(menu_sell_options)
menu_sell.setMenuStyleProperty(miniMenu.MenuStyleProperty.ScrollSpeed, 10000)
for (let index = 0; index < menu_sell_last_index; index++) {
menu_sell.moveSelection(miniMenu.MoveDirection.Down)
}
menu_sell.setMenuStyleProperty(miniMenu.MenuStyleProperty.ScrollSpeed, 150)
menu_sell.setFlag(SpriteFlag.RelativeToCamera, true)
menu_sell.top = 4
menu_sell.left = 4
menu_sell.z = 20
style_menu([menu_sell], scene.screenWidth() - 8, scene.screenHeight() - 32, "Sell vegetables")
menu_sell.setButtonEventsEnabled(false)
menu_sell.onButtonPressed(controller.A, function (selection, selectedIndex) {
if (selectedIndex == 0) {
menu_sell_last_index = 0
menu_sell_selections = []
menu_sell_selections_max = []
menu_sell.destroy()
open_action_menu()
} else if (selectedIndex == 1) {
money += sell_price
if (money >= money_goal) {
timer.after(100, function () {
game.over(true)
})
}
real_index = 0
indices_to_remove = []
index_remove_counts = []
for (let index = 0; index <= inventory.get_items().length - 1; index++) {
item = inventory.get_items()[index]
description = item.get_text(ItemTextAttribute.Description)
if (!(description)) {
continue;
}
if (item.get_text(ItemTextAttribute.Description).includes("sellable")) {
indices_to_remove.push(index)
index_remove_counts.push(menu_sell_selections[real_index])
real_index += 1
}
}
while (indices_to_remove.length > 0) {
change_stackable_item_count_inventory_index(indices_to_remove.pop(), index_remove_counts.pop() * -1)
}
menu_sell_selections = []
menu_sell_selections_max = []
menu_sell.destroy()
enable_movement(true)
in_menu = false
the_player.y += 16
} else {
if (menu_sell_selections[selectedIndex - 2] < menu_sell_selections_max[selectedIndex - 2]) {
menu_sell_selections[selectedIndex - 2] = menu_sell_selections[selectedIndex - 2] + 1
menu_sell_last_index = selectedIndex
menu_sell.destroy()
open_sell_menu()
}
}
})
menu_sell.onButtonPressed(controller.B, function (selection, selectedIndex) {
if (selectedIndex == 0 || selectedIndex == 1) {
menu_sell_last_index = 0
menu_sell_selections = []
menu_sell_selections_max = []
menu_sell.destroy()
open_action_menu()
} else {
if (menu_sell_selections[selectedIndex - 2] > 0) {
menu_sell_selections[selectedIndex - 2] = menu_sell_selections[selectedIndex - 2] - 1
menu_sell_last_index = selectedIndex
menu_sell.destroy()
open_sell_menu()
}
}
})
menu_sell.onButtonPressed(controller.menu, function (selection, selectedIndex) {
if (selectedIndex == 0 || selectedIndex == 1) {
} else {
if (menu_sell_selections[selectedIndex - 2] > 0) {
menu_sell_selections[selectedIndex - 2] = 0
} else {
menu_sell_selections[selectedIndex - 2] = menu_sell_selections_max[selectedIndex - 2]
}
menu_sell_last_index = selectedIndex
menu_sell.destroy()
open_sell_menu()
}
})
timer.background(function () {
while (controller.A.isPressed()) {
pause(0)
}
menu_sell.setButtonEventsEnabled(true)
})
}
function change_stackable_item_count_name (name: string, by: number) {
item = get_stackable_item_name(name)
if (item.get_text(ItemTextAttribute.Tooltip) == "") {
item.set_text(ItemTextAttribute.Tooltip, "1")
}
item.set_text(ItemTextAttribute.Tooltip, "" + (parseFloat(item.get_text(ItemTextAttribute.Tooltip)) + by))
if (item.get_text(ItemTextAttribute.Tooltip) == "1") {
item.set_text(ItemTextAttribute.Tooltip, "")
} else if (item.get_text(ItemTextAttribute.Tooltip) == "0") {
toolbar.get_items().removeAt(toolbar.get_number(ToolbarNumberAttribute.SelectedIndex))
}
toolbar.update()
inventory.update()
}
function remove_decoration (loc_in_list: any[]) {
for (let the_decoration of sprites.allOfKind(SpriteKind.Decoration)) {
if (same_locations([loc_in_list[0], the_decoration.tilemapLocation()])) {
the_decoration.destroy()
}
}
}
controller.right.onEvent(ControllerButtonEvent.Repeated, function () {
if (in_inventory) {
move_right_in_inventory_toolbar()
}
})
function load_environment_outside () {
scene.setBackgroundColor(7)
if (DEBUG_tilemap) {
tiles.setCurrentTilemap(tilemap`outside_debug`)
} else {
tiles.setCurrentTilemap(tilemap`outside`)
}
scene.cameraFollowSprite(the_player)
the_house = sprites.create(assets.image`house`, SpriteKind.House)
tiles.placeOnTile(the_house, tiles.getTilesByType(assets.tile`house`)[0])
the_house.y += -16
the_house.z = the_house.bottom / 100
rng_ground = Random.createRNG(2)
for (let index = 0; index < 50; index++) {
tiles.setTileAt(rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`)), sprites.castle.tileGrass1)
}
for (let index = 0; index < 40; index++) {
tiles.setTileAt(rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`)), sprites.castle.tileGrass3)
}
for (let index = 0; index < 30; index++) {
tiles.setTileAt(rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`)), sprites.castle.tileGrass2)
}
for (let index = 0; index < 5; index++) {
place_decoration(sprites.castle.rock1, [rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`))], 0, false)
}
for (let index = 0; index < 5; index++) {
place_decoration(assets.tile`stump`, [rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`))], 0, false)
}
for (let index = 0; index < 5; index++) {
place_decoration(sprites.castle.rock0, [rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`))], 0, false)
}
for (let index = 0; index < 20; index++) {
place_decoration(assets.image`flower_1`, [rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`))], 2 / 16, true)
}
for (let index = 0; index < 20; index++) {
place_decoration(assets.image`flower_2`, [rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`))], 2 / 16, true)
}
for (let index = 0; index < 10; index++) {
place_decoration(assets.image`flower_3`, [rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`))], 3 / 16, true)
}
for (let index = 0; index < 10; index++) {
place_decoration(assets.image`flower_4`, [rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`))], 3 / 16, true)
}
for (let index = 0; index < 5; index++) {
place_decoration(assets.image`flower_5`, [rng_ground.randomElement(tiles.getTilesByType(assets.tile`grass`))], 3 / 16, true)
}
}
controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
if (in_inventory) {
move_left_in_inventory_toolbar()
}
})
function style_menu (menu_in_list: any[], width: number, height: number, title: string) {
menu_in_list[0].setDimensions(width, height)
menu_in_list[0].setTitle(title)
menu_in_list[0].setMenuStyleProperty(miniMenu.MenuStyleProperty.Border, 1)
menu_in_list[0].setMenuStyleProperty(miniMenu.MenuStyleProperty.BorderColor, images.colorBlock(12))
menu_in_list[0].setMenuStyleProperty(miniMenu.MenuStyleProperty.BackgroundColor, images.colorBlock(13))
menu_in_list[0].setMenuStyleProperty(miniMenu.MenuStyleProperty.ScrollIndicatorColor, images.colorBlock(12))
menu_in_list[0].setStyleProperty(miniMenu.StyleKind.Default, miniMenu.StyleProperty.Foreground, images.colorBlock(12))
menu_in_list[0].setStyleProperty(miniMenu.StyleKind.Default, miniMenu.StyleProperty.Background, images.colorBlock(13))
menu_in_list[0].setStyleProperty(miniMenu.StyleKind.Selected, miniMenu.StyleProperty.Foreground, images.colorBlock(13))
menu_in_list[0].setStyleProperty(miniMenu.StyleKind.Selected, miniMenu.StyleProperty.Background, images.colorBlock(11))
menu_in_list[0].setStyleProperty(miniMenu.StyleKind.Title, miniMenu.StyleProperty.Foreground, images.colorBlock(13))
menu_in_list[0].setStyleProperty(miniMenu.StyleKind.Title, miniMenu.StyleProperty.Background, images.colorBlock(12))
}
function give_starting_items () {
inventory.get_items().push(Inventory.create_item("Pickaxe", assets.image`pickaxe_1`))
inventory.get_items().push(Inventory.create_item("Axe", assets.image`axe`))
inventory.get_items().push(Inventory.create_item("Shovel", assets.image`shovel`))
inventory.get_items().push(Inventory.create_item("Hoe", assets.image`hoe`))
inventory.get_items().push(create_item_with_tooltip("Watering can", assets.image`watering_can`, "", "0%"))
seed_rng = Random.createRNG(3)
inventory.get_items().push(create_item_with_tooltip("Potato", assets.image`potato`, "0.25,sellable,", "" + seed_rng.randomRange(5, 10)))
inventory.get_items().push(create_item_with_tooltip("Carrot seed", assets.image`carrot_seed`, "0.1,sellable,", "" + seed_rng.randomRange(5, 10)))
inventory.get_items().push(create_item_with_tooltip("Beetroot seed", assets.image`beetroot_seed`, "0.15,sellable,", "" + seed_rng.randomRange(5, 10)))
inventory.get_items().push(create_item_with_tooltip("Lettuce seed", assets.image`lettuce_seed`, "0.2,sellable,", "" + seed_rng.randomRange(5, 10)))
inventory.update()
if (DEBUG_menu) {
toolbar.get_items().push(Inventory.create_item("Debug menu", assets.image`popup_debug_menu`))
toolbar.update()
}
}
function place_decoration (image2: Image, location_in_list: any[], shift_tiles_up: number, can_go_through: boolean) {
if (can_go_through) {
the_decoration = sprites.create(image2, SpriteKind.Decoration)
tiles.placeOnTile(the_decoration, location_in_list[0])
the_decoration.y += shift_tiles_up * -16
the_decoration.z = the_decoration.bottom / 100
the_decoration.setFlag(SpriteFlag.Ghost, true)
} else {
tiles.setTileAt(location_in_list[0], image2)
tiles.setWallAt(location_in_list[0], true)
}
}
function set_watering_can_fill (_new: number) {
item = get_stackable_item_name("Watering can")
item.set_text(ItemTextAttribute.Tooltip, "" + _new)
if (item.get_text(ItemTextAttribute.Tooltip).length < 3) {
item.set_text(ItemTextAttribute.Tooltip, "" + item.get_text(ItemTextAttribute.Tooltip) + "%")
}
toolbar.update()
inventory.update()
}
function move_down_in_inventory_toolbar () {
if (cursor_in_inventory) {
if (inventory.get_number(InventoryNumberAttribute.SelectedIndex) < inventory.get_items().length - 8) {
inventory.change_number(InventoryNumberAttribute.SelectedIndex, 8)
}
} else {
toolbar.set_number(ToolbarNumberAttribute.SelectedIndex, toolbar.get_number(ToolbarNumberAttribute.MaxItems) - 1)
}
}
function enable_movement (en: boolean) {
in_cutscene = !(en)
if (en) {
controller.moveSprite(the_player, 80, 80)
} else {
controller.moveSprite(the_player, 0, 0)
}
}
function open_debug_menu () {
enable_movement(false)
if (!(spriteutils.isDestroyed(menu_debug))) {
menu_debug.destroy()
}
in_menu = true
menu_debug = miniMenu.createMenu(
miniMenu.createMenuItem("Close"),
miniMenu.createMenuItem("Set seed count to 500"),
miniMenu.createMenuItem("Set watering can fill to 500"),
miniMenu.createMenuItem("Reset day clock"),
miniMenu.createMenuItem("Go to end of day"),
miniMenu.createMenuItem("Tick plants"),
miniMenu.createMenuItem("Increase stage of all plants"),
miniMenu.createMenuItem("Decrease stage of all plants"),
miniMenu.createMenuItem("Harvest all grown plants"),
miniMenu.createMenuItem("Remove all plants"),
miniMenu.createMenuItem("Water all dirt"),
miniMenu.createMenuItem("Till all wet dirt")
)
menu_debug.setFlag(SpriteFlag.RelativeToCamera, true)
menu_debug.top = 4
menu_debug.left = 4
menu_debug.z = 20
style_menu([menu_debug], scene.screenWidth() - 8, scene.screenHeight() - 32, "Debug menu")
menu_debug.setButtonEventsEnabled(false)
menu_debug.onButtonPressed(controller.A, function (selection, selectedIndex) {
if (selectedIndex == 0) {
menu_debug.destroy()
enable_movement(true)
in_menu = false
} else if (selectedIndex == 1) {
set_stackable_item_count_name("Potato", 500)
set_stackable_item_count_name("Carrot seed", 500)
set_stackable_item_count_name("Beetroot seed", 500)
set_stackable_item_count_name("Lettuce seed", 500)
} else if (selectedIndex == 2) {
set_watering_can_fill(500)
} else if (selectedIndex == 3) {
secs_left_in_day = 86400 - 8 * 3600
secs_elapsed_today = 8 * 3600
} else if (selectedIndex == 4) {
secs_left_in_day = 4 * 3600
secs_elapsed_today = 86400 - 4 * 3600
menu_debug.destroy()
in_menu = false
} else if (selectedIndex == 5) {
tick_time()
} else if (selectedIndex == 6) {
tick_plant(potato_stages, 100)
tick_plant(carrot_stages, 100)
tick_plant(beetroot_stages, 100)
tick_plant(lettuce_stages, 100)
} else if (selectedIndex == 7) {
tick_plant(potato_stages, -100)
tick_plant(carrot_stages, -100)
tick_plant(beetroot_stages, -100)
tick_plant(lettuce_stages, -100)
} else if (selectedIndex == 8) {
menu_debug.destroy()
enable_movement(true)
in_menu = false
for (let tile of fully_grown_tiles) {
for (let location of tiles.getTilesByType(tile)) {
for (let index = 0; index < randint(1, 2); index++) {
give_player_seed_of(tile_to_vegetable_name([location]))
pause(0)
}
for (let index = 0; index < randint(2, 4); index++) {
give_player_crop_of(tile_to_vegetable_name([location]))
pause(0)
}
tiles.setTileAt(location, assets.tile`tilled_wet_dirt`)
pause(0)
}
}
} else if (selectedIndex == 9) {
} else if (selectedIndex == 10) {
} else if (selectedIndex == 11) {
}
})
menu_debug.onButtonPressed(controller.B, function (selection, selectedIndex) {
menu_debug.destroy()
enable_movement(true)
in_menu = false
})
timer.background(function () {
while (controller.A.isPressed()) {
pause(0)
}
menu_debug.setButtonEventsEnabled(true)
})
}
function update_action_label () {
if (tile_at_loc_is_one_of([the_cursor.tilemapLocation()], [
assets.tile`grass`,
sprites.castle.tileGrass1,
sprites.castle.tileGrass3,
sprites.castle.tileGrass2
]) && is_name_of_selected_item("Shovel")) {
label = "Remove grass"
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`stump`) && is_name_of_selected_item("Axe")) {
label = "Remove stump"
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`wet_dirt`) && is_name_of_selected_item("Hoe")) {
label = "Till dirt"
} else if (tile_at_loc_is_one_of([the_cursor.tilemapLocation()], [sprites.castle.rock0, sprites.castle.rock1]) && is_name_of_selected_item("Pickaxe")) {
label = "Remove rock"
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`water`) && is_name_of_selected_item("Watering can") && get_watering_can_fill() < 100) {
label = "Fill watering can"
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), sprites.castle.tilePath5) && is_name_of_selected_item("Watering can") && get_watering_can_fill() >= 10) {
label = "Water dirt"
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`) && is_name_of_selected_item("Potato")) {
label = "Plant seed"
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`) && is_name_of_selected_item("Carrot seed")) {
label = "Plant seed"
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`) && is_name_of_selected_item("Beetroot seed")) {
label = "Plant seed"
} else if (tiles.tileAtLocationEquals(the_cursor.tilemapLocation(), assets.tile`tilled_wet_dirt`) && is_name_of_selected_item("Lettuce seed")) {
label = "Plant seed"
} else if (is_name_of_selected_item("Debug menu")) {
label = "Open debug menu"
} else if (tile_at_loc_is_one_of([the_cursor.tilemapLocation()], non_fully_grown) && is_name_of_selected_item("Hoe")) {
label = "Uproot plant"
} else if (tile_at_loc_is_one_of([the_cursor.tilemapLocation()], fully_grown_tiles) && is_name_of_selected_item("Hoe")) {
label = "Harvest plant"
} else {
label = ""
}
action_label.setText(label)
action_label.right = scene.screenWidth() - 4
return label != ""
}
controller.right.onEvent(ControllerButtonEvent.Pressed, function () {
if (in_inventory) {
move_right_in_inventory_toolbar()
}
})
function update_time () {
secs_left_in_day += (game.runtime() - last_time) / 1000 * time_speed_multiplier * -1
last_time = game.runtime()
if (secs_left_in_day < 0) {
secs_left_in_day = 86400 - Math.abs(secs_left_in_day)
}
secs_elapsed_today = 86400 - secs_left_in_day
time_label.setText("" + index_to_short_day_of_week(day_of_the_week) + " " + format_time(secs_elapsed_today))
time_label.right = scene.screenWidth() - 4
}
function handle_a_key_in_inventory_toolbar () {
if (cursor_in_inventory) {
if (toolbar.get_items().length < toolbar.get_number(ToolbarNumberAttribute.MaxItems)) {
toolbar.get_items().push(inventory.get_items().removeAt(inventory.get_number(InventoryNumberAttribute.SelectedIndex)))
handle_b_key_in_inventory_toolbar()
toolbar.set_number(ToolbarNumberAttribute.SelectedIndex, toolbar.get_items().length - 1)
}
} else {
if (inventory.get_items().length < inventory.get_number(InventoryNumberAttribute.MaxItems) && toolbar.get_number(ToolbarNumberAttribute.SelectedIndex) < toolbar.get_items().length) {
inventory.get_items().push(toolbar.get_items().removeAt(toolbar.get_number(ToolbarNumberAttribute.SelectedIndex)))
handle_b_key_in_inventory_toolbar()
inventory.set_number(InventoryNumberAttribute.SelectedIndex, inventory.get_items().length - 1)
}
}
toolbar.update()
inventory.update()
}
function make_player () {
the_player = sprites.create(assets.image`player_facing_forward`, SpriteKind.Player)
the_player.z = 10
enable_movement(true)
animate_sprite(the_player, assets.animation`player_walk_upwards`[1], characterAnimations.rule(Predicate.FacingUp, Predicate.NotMoving), assets.animation`player_walk_upwards`, characterAnimations.rule(Predicate.MovingUp))
animate_sprite(the_player, assets.animation`player_walk_right`[1], characterAnimations.rule(Predicate.FacingRight, Predicate.NotMoving), assets.animation`player_walk_right`, characterAnimations.rule(Predicate.MovingRight))
animate_sprite(the_player, assets.animation`player_walk_down`[1], characterAnimations.rule(Predicate.FacingDown, Predicate.NotMoving), assets.animation`player_walk_down`, characterAnimations.rule(Predicate.MovingDown))
animate_sprite(the_player, assets.animation`player_walk_left`[1], characterAnimations.rule(Predicate.FacingLeft, Predicate.NotMoving), assets.animation`player_walk_left`, characterAnimations.rule(Predicate.MovingLeft))
}
function change_watering_can_fill (by: number) {
item = get_stackable_item_name("Watering can")
item.set_text(ItemTextAttribute.Tooltip, "" + Math.constrain(parseFloat(item.get_text(ItemTextAttribute.Tooltip)) + by, 0, 100))
if (item.get_text(ItemTextAttribute.Tooltip).length < 3) {
item.set_text(ItemTextAttribute.Tooltip, "" + item.get_text(ItemTextAttribute.Tooltip) + "%")
}
toolbar.update()
inventory.update()
}
function give_player_crop_of (name: string) {
if (name == "potato") {
add_item([Inventory.create_item("Potato", assets.image`potato`, "0.25,sellable,")])
} else if (name == "carrot") {
add_item([Inventory.create_item("Carrot", assets.image`carrot`, "0.2,sellable,")])
} else if (name == "beetroot") {
add_item([Inventory.create_item("Beetroot", assets.image`beetroot`, "0.3,sellable,")])
} else if (name == "lettuce") {
add_item([Inventory.create_item("Lettuce", assets.image`lettuce`, "1,sellable,")])
}
}
function tick_plant (stages: any[], percent_chance: number) {
if (percent_chance < 0) {
for (let index = 0; index <= stages.length - 1; index++) {
for (let location of tiles.getTilesByType(stages[index])) {
if (Math.percentChance(Math.abs(percent_chance))) {
tiles.setTileAt(location, stages[Math.max(index - 1, 0)])
}
}
}
} else {
for (let index = 0; index <= stages.length - 1; index++) {
for (let location of tiles.getTilesByType(stages[stages.length - 1 - index])) {
if (Math.percentChance(percent_chance)) {
tiles.setTileAt(location, stages[Math.min(stages.length - 1 - index + 1, stages.length - 1)])
}
}
}
}
}
function update_money_label () {
if (money == 0) {
money_label.setText("$0/" + money_goal)
} else if (money * 100 % 10 == 0) {
money_label.setText("$" + money + "0/" + money_goal)
} else {
money_label.setText("$" + money + "/" + money_goal)
}
}
controller.down.onEvent(ControllerButtonEvent.Repeated, function () {
if (in_inventory) {
move_down_in_inventory_toolbar()
}
})
function index_to_short_day_of_week (idx: number) {
days_of_week_names = [
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun"
]
return days_of_week_names[idx % days_of_week_names.length]
}
controller.down.onEvent(ControllerButtonEvent.Pressed, function () {
if (in_inventory) {
move_down_in_inventory_toolbar()
}
})
function move_left_in_inventory_toolbar () {
if (cursor_in_inventory) {
if (inventory.get_number(InventoryNumberAttribute.SelectedIndex) % 8 > 0) {
inventory.change_number(InventoryNumberAttribute.SelectedIndex, -1)
}
} else {
if (toolbar.get_number(ToolbarNumberAttribute.SelectedIndex) > 0) {
toolbar.change_number(ToolbarNumberAttribute.SelectedIndex, -1)
}
}
}
function move_right_in_inventory_toolbar () {
if (cursor_in_inventory) {
if (inventory.get_number(InventoryNumberAttribute.SelectedIndex) % 8 < 7 && inventory.get_number(InventoryNumberAttribute.SelectedIndex) < inventory.get_items().length - 1) {
inventory.change_number(InventoryNumberAttribute.SelectedIndex, 1)
}
} else {
if (toolbar.get_number(ToolbarNumberAttribute.SelectedIndex) < toolbar.get_number(ToolbarNumberAttribute.MaxItems) - 1) {
toolbar.change_number(ToolbarNumberAttribute.SelectedIndex, 1)
}
}
}
function screen_shade (amount: number) {
if (!(spriteutils.isDestroyed(screen_shader))) {
screen_shader.destroy()
}
if (amount == -1) {
return
}
screen_shader = shader.createRectangularShaderSprite(scene.screenWidth(), scene.screenHeight(), amount)
screen_shader.setFlag(SpriteFlag.RelativeToCamera, true)
screen_shader.setPosition(scene.screenWidth() / 2, scene.screenHeight() / 2)
}
controller.menu.onEvent(ControllerButtonEvent.Pressed, function () {
if (in_inventory) {
handle_menu_key_in_inventory_toolbar()
} else if (in_menu) {
} else {
handle_menu_key_in_inventory_toolbar()
}
})
controller.A.onEvent(ControllerButtonEvent.Repeated, function () {
if (in_inventory) {
} else if (in_menu) {
} else {
do_action()
}
})
function same_locations (locs_in_list: any[]) {
col = locs_in_list[0].column
row = locs_in_list[0].row
for (let location of locs_in_list) {
if (col != location.column) {
return false
}
if (row != location.row) {
return false
}
}
return true
}
function on_day_end_of_last_day () {
enable_movement(false)
screen_shade(shader.ShadeLevel.Two)
scene.followPath(the_player, scene.aStar(the_player.tilemapLocation(), tiles.getTilesByType(assets.tile`house`)[0]), 40)
while (scene.spriteIsFollowingPath(the_player)) {
pause(0)
}
}
function set_stackable_item_count_name (name: string, _new: number) {
item = get_stackable_item_name(name)
item.set_text(ItemTextAttribute.Tooltip, "" + _new)
if (item.get_text(ItemTextAttribute.Tooltip) == "1") {
item.set_text(ItemTextAttribute.Tooltip, "")
} else if (item.get_text(ItemTextAttribute.Tooltip) == "0") {
toolbar.get_items().removeAt(toolbar.get_number(ToolbarNumberAttribute.SelectedIndex))
}
toolbar.update()
inventory.update()
}
function get_watering_can_fill () {
return parseFloat(get_stackable_item_name("Watering can").get_text(ItemTextAttribute.Tooltip))
}
function get_stackable_item_count () {
return parseFloat(toolbar.get_items()[toolbar.get_number(ToolbarNumberAttribute.SelectedIndex)].get_text(ItemTextAttribute.Tooltip))
}
function change_stackable_item_count_inventory_index (idx: number, by: number) {
item = inventory.get_items()[idx]
if (item.get_text(ItemTextAttribute.Tooltip) == "") {
item.set_text(ItemTextAttribute.Tooltip, "1")
}
item.set_text(ItemTextAttribute.Tooltip, "" + (parseFloat(item.get_text(ItemTextAttribute.Tooltip)) + by))
if (item.get_text(ItemTextAttribute.Tooltip) == "1") {
item.set_text(ItemTextAttribute.Tooltip, "")
} else if (item.get_text(ItemTextAttribute.Tooltip) == "0") {
inventory.get_items().removeAt(idx)
}
inventory.update()
}
function handle_menu_key_in_inventory_toolbar () {
in_inventory = !(in_inventory)
inventory.setFlag(SpriteFlag.Invisible, !(in_inventory))
enable_movement(!(in_inventory))
cursor_in_inventory = false
if (in_inventory) {
inventory.set_number(InventoryNumberAttribute.SelectedIndex, -1)
last_toolbar_select = toolbar.get_number(ToolbarNumberAttribute.SelectedIndex)
} else {
toolbar.set_number(ToolbarNumberAttribute.SelectedIndex, last_toolbar_select)
if (inventory.get_number(InventoryNumberAttribute.SelectedIndex) != -1) {
last_inventory_select = inventory.get_number(InventoryNumberAttribute.SelectedIndex)
}
}
}
function fade (in_or_out: boolean, block: boolean) {
if (in_or_out) {
color.startFade(color.originalPalette, color.Black, 2000)
} else {
color.startFade(color.Black, color.originalPalette, 2000)
}
if (block) {
color.pauseUntilFadeDone()
}
}
function move_up_in_inventory_toolbar () {
if (cursor_in_inventory) {
if (inventory.get_number(InventoryNumberAttribute.SelectedIndex) > 7) {
inventory.change_number(InventoryNumberAttribute.SelectedIndex, -8)
}