-
Notifications
You must be signed in to change notification settings - Fork 4
/
types.d.ts
2380 lines (2363 loc) · 95.1 KB
/
types.d.ts
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
declare module "index" {
/**
* Extracts values from dictionary into global scope
* @param dict - Dictionary to extract
*/
function extract(dict: dictionary): void;
/**
* Creates and returns an unavailable group ID
* @returns Resulting group ID
*/
function unknown_g(): group;
/**
* Creates and returns an unavailable color ID
* @returns Resulting color ID
*/
function unknown_c(): color;
/**
* Creates and returns an unavailable block ID
* @returns Resulting block ID
*/
function unknown_b(): block;
/**
* @property name - Name of the current context
* @property group - Group representing the current context
* @property objects - All objects in the current context
* @property children - Child contexts
*/
type context = {
name: string;
group: group;
objects: any[];
children: any[];
};
/**
* Creates a new context
* @param name - Name of context
* @param [setToDefault = false] - Whether to automatically switch to the context
* @param [group = unknown_g()] - The group to give to the context
*/
class Context {
constructor(name: string, setToDefault?: boolean, group?: group);
/**
* The name of the current context
*/
current: any;
/**
* A list of all contexts added
*/
list: any;
/**
* Switches the context
* @param name - Name or group of context to switch to
*/
static set(name: string | group): void;
/**
* Converts an object into a context
* @param context - Object to convert into a context
*/
static add(context: context): void;
/**
* Adds an object into the current context
* @param objectToAdd - Object to add into current context
*/
static addObject(objectToAdd: any): void;
/**
* Links an existing context into the current one, allowing you to find the parent context of another context
* @param context - Context to link into current
* @param ctxLink - Optional context that should be the parent of input context
*/
static link(context: context, ctxLink: string): void;
/**
* Checks if a context has a parent
* @param ctx - Context to check for parent
* @returns Whether context has a parent
*/
static isLinked(ctx: context): boolean;
/**
* Finds a context based off of its assigned group
* @returns Found context
*/
static findByGroup(groupToSearch: group): context;
/**
* Finds a context based off of its name
* @param name - Name of the context
* @returns Found context
*/
static findByName(name: string): context;
}
/**
* Creates a repeating trigger system that repeats while a condition is true
* @param condition - Condition that defines whether the loop should keep on running (less_than/equal_to/greater_than(counter, number))
* @param func - Function to run while the condition is true
* @param delay - Delay between each cycle
*/
function while_loop(condition: condition, func: (...params: any[]) => any, delay: number): void;
/**
* @property type - String dictating that the type of the resulting dictionary is an object
* @property obj_props - Dictionary inside of object holding the actual object properties of the object
* @property with - Modifies/adds an object property (e.g. `object.with(obj_props.X, 15)`)
* @property add - Adds the object
*/
type object = dictionary;
/**
* @property type - String dictating that the type of the resulting dictionary is an object
* @property obj_props - Dictionary inside of object holding the actual object properties of the object
* @property with - Modifies/adds an object property (e.g. `object.with(obj_props.X, 15)`)
* @property add - Adds the object
*/
type object = dictionary;
/**
* Creates a "trigger function" in which triggers can be stored inside of a single group
* @param callback - Function storing triggers to put inside of group
* @returns Group ID of trigger function
*/
function trigger_function(callback: (...params: any[]) => any): group;
/**
* Waits for a specific amount of seconds
* @param time - How long to wait
*/
function wait(time: number): void;
/**
* Helper functions and variables holding existing level info.
*/
namespace level {
/**
* Array of all objects in the level.
*/
var objects: object[];
/**
* Raw level string of the current level.
*/
var raw_levelstring: string;
/**
* Returns an array of all the objects in the level with a property whose value matches the pattern.
* @param prop - The property to check in each object.
* @param pattern - The function to test the property value.
* @returns An array of objects that match the given property and pattern.
*/
function get_objects(prop: string | number, pattern: (...params: any[]) => any): object[];
}
/**
* @property EASE_IN_OUT - Ease in out easing
* @property EASE_IN - Ease in easing
* @property EASE_OUT - Ease out easing
* @property EXPONENTIAL_IN_OUT - Exponential in out easing
* @property EXPONENTIAL_IN - Exponential in easing
* @property EXPONENTIAL_OUT - Exponential out easing
* @property SINE_IN_OUT - Sine in out easing
* @property SINE_IN - Sine in easing
* @property SINE_OUT - Sine out easing
* @property ELASTIC_IN_OUT - Elastic in out easing
* @property ELASTIC_IN - Elastic in easing
* @property ELASTIC_OUT - Elastic out easing
* @property BACK_IN_OUT - Back in out easing
* @property BACK_IN - Back in easing
* @property BACK_OUT - Back out easing
* @property BOUNCE_IN_OUT - Bounce in out easing
* @property BOUNCE_IN - Bounce in easing
* @property BOUNCE_OUT - Bounce out easing
*/
type easing = {
EASE_IN_OUT: number;
EASE_IN: number;
EASE_OUT: number;
EXPONENTIAL_IN_OUT: number;
EXPONENTIAL_IN: number;
EXPONENTIAL_OUT: number;
SINE_IN_OUT: number;
SINE_IN: number;
SINE_OUT: number;
ELASTIC_IN_OUT: number;
ELASTIC_IN: number;
ELASTIC_OUT: number;
BACK_IN_OUT: number;
BACK_IN: number;
BACK_OUT: number;
BOUNCE_IN_OUT: number;
BOUNCE_IN: number;
BOUNCE_OUT: number;
};
/**
* @property type - Type of export (can be "levelstring", "savefile" or "live_editor")
* @property options - Configuration for specific export type
*/
type export_config = {
type: string;
options: save_config;
};
/**
* One-size-fits-all function for exporting a level to GD
* @param conf - Configuration for exporting level
* @returns Levelstring if using "levelstring" type, otherwise null
*/
function exportConfig(conf: export_config): null | string;
/**
* Configuration for exporting levels.
* @property [info = false] - Whether to log information to console when finished
* @property [group_count_warning = true] - Whether to warn that group count is surpassed (only useful if in future updates the group count is increased)
* @property [level_name = by default, it writes to your most recent level/topmost level] - Name of level (only for exportToSavefile)
* @property [path = path to savefile automatically detected based off of OS] - Path to CCLocalLevels.dat savefile (only for exportToSavefile)
* @property [reencrypt = true] - Whether to reencrypt savefile after editing it, or to let GD encrypt it
* @property [optimize = true] - Whether to optimize unused groups & triggers that point to unused groups
* @property [replacePastObjects = true] - Whether to delete all objects added by G.js in the past & replace them with the new objects
* @property [removeGroup = 9999] - Group to use to mark objects to be automatically deleted when re-running the script (default is 9999)
*/
type save_config = {
info?: boolean;
group_count_warning?: boolean;
level_name?: string;
path?: string;
reencrypt?: boolean;
optimize?: boolean;
replacePastObjects?: boolean;
removeGroup?: number | group;
};
/**
* Core type holding important functions for adding to levels, exporting, and modifying scripts.
*/
namespace $ {
/**
* Adds an object.
*/
var add: any;
/**
* Prints to console.
* @param value - Value to print.
*/
function print(value: any): void;
/**
* Returns level string of the script.
*/
var getLevelString: any;
/**
* Exports script to savefile.
*/
var exportToSavefile: any;
/**
* Exports script to live editor using WSLiveEditor (requires Geode).
*/
var liveEditor: any;
/**
* Maps every trigger that gets added to the level
*/
var callback_objects: any;
/**
* Extends a trigger function by adding more triggers to it.
*/
var extend_trigger_func: any;
/**
* Returns group of current trigger function context.
* @returns Group of current trigger function context.
*/
function trigger_fn_context(): group;
}
/**
* Ignores context changes inside of a function
* @param fn - Function containing code where context changes should be ignored
*/
function ignore_context_change(fn: (...params: any[]) => any): void;
/**
* Generates an array holding a sequence of numbers starting at the "start" parameter, ending at the "end" parameter and incrementing by "step"
* @param start - What number to start at
* @param end - What number to end at
* @param step - What number to increment by
* @returns Resulting sequence
*/
function range(start: number, end: number, step?: number): any[];
/**
* @property USER_COIN - Identifier for user coin
* @property H_BLOCK - Identifier for H block
* @property J_BLOCK - Identifier for J block
* @property TEXT - Identifier for text
* @property S_BLOCK - Identifier for S block
* @property ITEM_DISPLAY - Identifier for item display
* @property D_BLOCK - Identifier for D block
* @property COLLISION_BLOCK - Identifier for collision block
*/
type special_objects = {
USER_COIN: number;
H_BLOCK: number;
J_BLOCK: number;
TEXT: number;
S_BLOCK: number;
ITEM_DISPLAY: number;
D_BLOCK: number;
COLLISION_BLOCK: number;
};
/**
* @property SPAWN - Identifier for spawn trigger
* @property ON_DEATH - Identifier for on-death trigger
* @property ROTATE - Identifier for rotate trigger
* @property COUNT - Identifier for count trigger
* @property DISABLE_TRAIL - Identifier for disable trail trigger
* @property HIDE - Identifier for hide trigger
* @property PICKUP - Identifier for pickup trigger
* @property COLLISION - Identifier for collision trigger
* @property ENABLE_TRAIL - Identifier for enable trail trigger
* @property ANIMATE - Identifier for animate trigger
* @property TOUCH - Identifier for touch trigger
* @property INSTANT_COUNT - Identifier for instant count trigger
* @property BG_EFFECT_OFF - Identifier for BG effect off trigger
* @property TOGGLE - Identifier for toggle trigger
* @property MOVE - Identifier for move trigger
* @property ALPHA - Identifier for alpha trigger
* @property SHOW - Identifier for show trigger
* @property STOP - Identifier for stop trigger
* @property FOLLOW - Identifier for follow trigger
* @property PULSE - Identifier for pulse trigger
* @property BG_EFFECT_ON - Identifier for BG effect on trigger
* @property SHAKE - Identifier for shake trigger
* @property FOLLOW_PLAYER_Y - Identifier for follow player Y trigger
* @property COLOR - Identifier for color trigger
*/
type trigger_ids = {
SPAWN: number;
ON_DEATH: number;
ROTATE: number;
COUNT: number;
DISABLE_TRAIL: number;
HIDE: number;
PICKUP: number;
COLLISION: number;
ENABLE_TRAIL: number;
ANIMATE: number;
TOUCH: number;
INSTANT_COUNT: number;
BG_EFFECT_OFF: number;
TOGGLE: number;
MOVE: number;
ALPHA: number;
SHOW: number;
STOP: number;
FOLLOW: number;
PULSE: number;
BG_EFFECT_ON: number;
SHAKE: number;
FOLLOW_PLAYER_Y: number;
COLOR: number;
};
/**
* @property SPEED_GREEN - Identifier for green speed portal
* @property TELEPORT - Identifier for teleport portal
* @property CUBE - Identifier for cube portal
* @property MIRROR_OFF - Identifier for mirror off portal
* @property WAVE - Identifier for wave portal
* @property SPIDER - Identifier for spider portal
* @property SPEED_RED - Identifier for red speed portal
* @property GRAVITY_DOWN - Identifier for gravity down portal
* @property SPEED_BLUE - Identifier for blue speed portal
* @property UFO - Identifier for UFO portal
* @property ROBOT - Identifier for robot portal
* @property MIRROR_ON - Identifier for mirror on portal
* @property GRAVITY_UP - Identifier for gravity up portal
* @property DUAL_ON - Identifier for dual on portal
* @property SIZE_MINI - Identifier for mini size portal
* @property BALL - Identifier for ball portal
* @property SIZE_NORMAL - Identifier for normal size portal
* @property SHIP - Identifier for ship portal
* @property SPEED_PINK - Identifier for pink speed portal
* @property SPEED_YELLOW - Identifier for yellow speed portal
* @property DUAL_OFF - Identifier for dual off portal
*/
type portal_ids = {
SPEED_GREEN: number;
TELEPORT: number;
CUBE: number;
MIRROR_OFF: number;
WAVE: number;
SPIDER: number;
SPEED_RED: number;
GRAVITY_DOWN: number;
SPEED_BLUE: number;
UFO: number;
ROBOT: number;
MIRROR_ON: number;
GRAVITY_UP: number;
DUAL_ON: number;
SIZE_MINI: number;
BALL: number;
SIZE_NORMAL: number;
SHIP: number;
SPEED_PINK: number;
SPEED_YELLOW: number;
DUAL_OFF: number;
};
/**
* @property special - Special object IDs
* @property triggers - Trigger object IDs
* @property portals - Portal object IDs
*/
type obj_ids = {
special: special_objects;
triggers: trigger_ids;
portals: portal_ids;
};
/**
* @property special - Special object IDs
* @property triggers - Trigger object IDs
* @property portals - Portal object IDs
*/
type obj_ids = {
special: special_objects;
triggers: trigger_ids;
portals: portal_ids;
};
/**
* @property bite - Identifier for the bite animation
* @property attack01 - Identifier for the first attack animation
* @property attack01_end - Identifier for the end of the first attack animation
* @property idle01 - Identifier for the first idle animation
*/
type big_beast_animations = {
bite: number;
attack01: number;
attack01_end: number;
idle01: number;
};
/**
* @property idle01 - Identifier for the first idle animation
* @property idle02 - Identifier for the second idle animation
* @property idle03 - Identifier for the third idle animation
* @property attack01 - Identifier for the first attack animation
* @property attack02 - Identifier for the second attack animation
* @property attack02_end - Identifier for the end of the second attack animation
* @property sleep - Identifier for the sleep animation
* @property sleep_loop - Identifier for the sleep loop animation
* @property sleep_end - Identifier for the end of the sleep animation
* @property attack02_loop - Identifier for the loop of the second attack animation
*/
type bat_animations = {
idle01: number;
idle02: number;
idle03: number;
attack01: number;
attack02: number;
attack02_end: number;
sleep: number;
sleep_loop: number;
sleep_end: number;
attack02_loop: number;
};
/**
* @property idle01 - Identifier for the first idle animation
* @property idle02 - Identifier for the second idle animation
* @property toAttack01 - Identifier for the transition to the first attack animation
* @property attack01 - Identifier for the first attack animation
* @property attack02 - Identifier for the second attack animation
* @property toAttack03 - Identifier for the transition to the third attack animation
* @property attack03 - Identifier for the third attack animation
* @property idle03 - Identifier for the third idle animation
* @property fromAttack03 - Identifier for the transition from the third attack animation
*/
type spikeball_animations = {
idle01: number;
idle02: number;
toAttack01: number;
attack01: number;
attack02: number;
toAttack03: number;
attack03: number;
idle03: number;
fromAttack03: number;
};
/**
* @property big_beast - Animation identifiers for big beast
* @property bat - Animation identifiers for bat
* @property spikeball - Animation identifiers for spikeball
*/
type animations = {
big_beast: big_beast_animations;
bat: bat_animations;
spikeball: spikeball_animations;
};
/**
* @property big_beast - Animation identifiers for big beast
* @property bat - Animation identifiers for bat
* @property spikeball - Animation identifiers for spikeball
*/
type animations = {
big_beast: big_beast_animations;
bat: bat_animations;
spikeball: spikeball_animations;
};
}
/**
* Converts a number to a group
* @param x - The number to convert to a group.
*/
declare function group(x: number): group;
/**
* Converts a number to a color
* @param x - The number to convert to a color.
*/
declare function color(x: number): color;
/**
* Converts a number to a block
* @param x - The number to convert to a block.
*/
declare function block(x: number): block;
declare module "control-flow" {
/**
* Creates a spawn trigger and returns it
* @param group - group to be spawned
* @param time - delay to spawn group
*/
function spawn_trigger(group: group, time: number): any;
/**
* Creates a loop that repeats every frame
* @param trigger_function - The group to call every frame
* @returns Group that can be used to stop the loop
*/
function frame_loop(trigger_function: group): group;
/**
* Waits a specific amount of frames
* @param frames - How many frames to wait for
*/
function frames(frames: number): void;
/**
* Returns a greater than condition
* @param counter - Counter to compare to number
* @param other - Number to be compared to counter
*/
function greater_than(counter: counter, other: number): condition;
/**
* Returns a equal to condition
* @param counter - Counter to compare to number
* @param other - Number to be compared to counter
*/
function equal_to(counter: counter, other: number): condition;
/**
* Returns a less than condition
* @param counter - Counter to compare to number
* @param other - Number to be compared to counter
*/
function less_than(counter: counter, other: number): condition;
/**
* Calls a group with a delay
* @param delay - How much to delay by
* @param group - Group to call
*/
function call_with_delay(delay: number, group: group): void;
/**
* Implementation of sequence trigger
* @param sequence - Sequence of groups to be called (e.g. [[group(1), 1], [group(2), 1]] is a valid input)
* @param [mode = 0] - Mode of sequence trigger (0 = stop, 1 = loop, 2 = last)
* @param [min_int = 0] - MinInt of sequence trigger
* @param [reset = 0] - Reset of sequence trigger (0 = full, 1 = step)
* @returns Function that steps through the sequence once
*/
function sequence(sequence: any[], mode?: number, min_int?: number, reset?: number): (...params: any[]) => any;
/**
* Creates trigger function-like systems, but can be called normally with item IDs as arguments (e.g. a remappable can be called like `my_remappable(counter1.item)`)
* @param fn - Function that remappable uses
* @returns Function to call
*/
function remappable(fn: (...params: any[]) => any): (...params: any[]) => any;
/**
* Loops a function a specific amount of times (defined by range)
* @param range - Range of numbers defining how many times to loop fn by
* @param fn - Function to loop
* @param [delay = 0.05] - How much to delay between cycle
*/
function for_loop(range: any[], fn: (...params: any[]) => any, delay?: number): void;
}
declare module "counter" {
/**
* Represents a counter, which is a wrapper around item IDs
* @property item - Item ID of a counter
* @property type - Type of a counter
* @property add - Adds a specific amount (or another counter) to the current counter
* @property subtract - Subtracts a specific amount (or another counter) from the current counter
* @property multiply - Multiplies the current counter by a specific amount (or another counter)
* @property divide - Divides the current counter by a specific amount (or another counter)
* @property set - Sets the current counter to a specific amount or another counter
* @property reset - Resets the current counter to 0
* @property if_is - Checks if a comparison is true, and if so calls a group (SMALLER_THAN/EQUAL_TO_LARGER_THAN)
* @property to_const - Converts the current counter to a plain number by taking in a range of possible values and a function
* @property copy_to - Copies the current counter to another counter
* @property display - Displays the current counter at a specific position
* @property to_obj - Returns item display for current counter as an object
* @property add_to - Adds the current counter to another and resets the current counter
* @property subtract_from - Subtracts the current counter from another and resets the current counter
* @property abs - Gets absolute value from counter
* @property neg - Converts value to negative value
*/
type counter = {
item: item;
type: item_type;
add: add;
subtract: subtract;
multiply: multiply;
divide: divide;
set: set;
reset: reset;
if_is: if_is;
to_const: to_const;
copy_to: copy_to;
display: display;
to_obj: to_obj;
add_to: add_to;
subtract_from: subtract_from;
abs: (...params: any[]) => any;
neg: (...params: any[]) => any;
};
/**
* Adds a specific amount (or another counter) to the current counter
* @param amount - Counter or number to add to the current counter
*/
type add = (amount: number | counter) => void;
/**
* Subtracts a specific amount (or another counter) from the current counter
* @param amount - Counter or number to subtract from the current counter
*/
type subtract = (amount: number | counter) => void;
/**
* Multiplies the current counter by a specific amount (or another counter)
* @param amount - Counter or number to multiply the current counter by
*/
type multiply = (amount: number | counter) => void;
/**
* Divides the current counter by a specific amount (or another counter)
* @param amount - Counter or number to divide the current counter by
*/
type divide = (amount: number | counter) => void;
/**
* Sets the current counter to a specific amount (or another counter)
* @param amount - Counter or number to set the current counter to
*/
type set = (amount: number | counter) => void;
/**
* Resets the current counter to 0
*/
type reset = () => void;
/**
* Returns item display for current counter as an object
*/
type to_obj = () => any;
/**
* Checks if a comparison is true, and if so calls a group (SMALLER_THAN/EQUAL_TO_LARGER_THAN)
* @param comparison - Condition to check for between the counter and number
* @param other - Number to compare the current counter to
* @param trig_func - Trigger function or group to run if the comparison is true
*/
type if_is = (comparison: comparison, other: number, trig_func: group) => void;
/**
* Converts the current counter to a plain number by taking in a range of possible values and a function
* @param range - Possible range of values that the current counter is equal to
* @param func - Callback function to run that takes the plain numerical value as input
*/
type to_const = (range: any[], func: (...params: any[]) => any) => void;
/**
* Displays the current counter at a specific position
* @param x - X position of item display
* @param y - Y position of item display
*/
type display = (x: number, y: number) => void;
/**
* Copies the current counter to another counter
* @param counter - Counter to copy the current counter to
*/
type copy_to = (counter: counter) => void;
/**
* Adds the current counter to another and resets the current counter
* @param counter - Counter to add the current counter to
*/
type add_to = (counter: counter) => void;
/**
* Subtracts the current counter from another and resets the current counter
* @param counter - Counter to be subtracted from
*/
type subtract_from = (counter: counter) => void;
/**
* Represents a counter, which is a wrapper around item IDs
* @property item - Item ID of a counter
* @property type - Type of a counter
* @property add - Adds a specific amount (or another counter) to the current counter
* @property subtract - Subtracts a specific amount (or another counter) from the current counter
* @property multiply - Multiplies the current counter by a specific amount (or another counter)
* @property divide - Divides the current counter by a specific amount (or another counter)
* @property set - Sets the current counter to a specific amount or another counter
* @property reset - Resets the current counter to 0
* @property if_is - Checks if a comparison is true, and if so calls a group (SMALLER_THAN/EQUAL_TO_LARGER_THAN)
* @property to_const - Converts the current counter to a plain number by taking in a range of possible values and a function
* @property copy_to - Copies the current counter to another counter
* @property display - Displays the current counter at a specific position
* @property to_obj - Returns item display for current counter as an object
* @property add_to - Adds the current counter to another and resets the current counter
* @property subtract_from - Subtracts the current counter from another and resets the current counter
* @property abs - Gets absolute value from counter
* @property neg - Converts value to negative value
*/
type counter = {
item: item;
type: item_type;
add: add;
subtract: subtract;
multiply: multiply;
divide: divide;
set: set;
reset: reset;
if_is: if_is;
to_const: to_const;
copy_to: copy_to;
display: display;
to_obj: to_obj;
add_to: add_to;
subtract_from: subtract_from;
abs: (...params: any[]) => any;
neg: (...params: any[]) => any;
};
/**
* Version of counter that supports floating point values
* @property item - Item ID of a counter
* @property type - Type of a counter
* @property add - Adds a specific amount (or another counter) to the current counter
* @property subtract - Subtracts a specific amount (or another counter) from the current counter
* @property multiply - Multiplies the current counter by a specific amount (or another counter)
* @property divide - Divides the current counter by a specific amount (or another counter)
* @property set - Sets the current counter to a specific amount or another counter
* @property reset - Resets the current counter to 0
* @property copy_to - Copies the current counter to another counter
* @property display - Displays the current counter at a specific position
* @property to_obj - Returns item display for current counter as an object
* @property add_to - Adds the current counter to another and resets the current counter
* @property subtract_from - Subtracts the current counter from another and resets the current counter
* @property abs - Gets absolute value from counter
* @property neg - Converts value to negative value
* @property round - Rounds the floating point value into an integer
*/
type float_counter = {
item: item;
type: item_type;
add: add;
subtract: subtract;
multiply: multiply;
divide: divide;
set: set;
reset: reset;
copy_to: copy_to;
display: display;
to_obj: to_obj;
add_to: add_to;
subtract_from: subtract_from;
abs: (...params: any[]) => any;
neg: (...params: any[]) => any;
round: (...params: any[]) => any;
};
/**
* Version of counter that supports floating point values
* @property item - Item ID of a counter
* @property type - Type of a counter
* @property add - Adds a specific amount (or another counter) to the current counter
* @property subtract - Subtracts a specific amount (or another counter) from the current counter
* @property multiply - Multiplies the current counter by a specific amount (or another counter)
* @property divide - Divides the current counter by a specific amount (or another counter)
* @property set - Sets the current counter to a specific amount or another counter
* @property reset - Resets the current counter to 0
* @property copy_to - Copies the current counter to another counter
* @property display - Displays the current counter at a specific position
* @property to_obj - Returns item display for current counter as an object
* @property add_to - Adds the current counter to another and resets the current counter
* @property subtract_from - Subtracts the current counter from another and resets the current counter
* @property abs - Gets absolute value from counter
* @property neg - Converts value to negative value
* @property round - Rounds the floating point value into an integer
*/
type float_counter = {
item: item;
type: item_type;
add: add;
subtract: subtract;
multiply: multiply;
divide: divide;
set: set;
reset: reset;
copy_to: copy_to;
display: display;
to_obj: to_obj;
add_to: add_to;
subtract_from: subtract_from;
abs: (...params: any[]) => any;
neg: (...params: any[]) => any;
round: (...params: any[]) => any;
};
}
declare module "events" {
/**
* Calls a group when an event occurs
* @param event - Event to listen to
* @param group - Group of object
*/
function on(event: event, group: group): void;
/**
* Listens to when the screen is touched
* @param [dual_side = false] - Whether to only listen to dual side
*/
function touch(dual_side?: boolean): event;
/**
* Event that runs on every frame
*/
function frame(): void;
/**
* Listens to when the screen stops being touched
* @param [dual_side = false] - Whether to only listen to dual side
*/
function touch_end(dual_side?: boolean): event;
/**
* Listens to when two collision blocks collide
* @param block_a - First block to listen to
* @param block_b - Second block to listen to
* @param P1 - Player 1 as block a
* @param P2 - Player 2 as block a
*/
function collision(block_a: block, block_b: block, P1: boolean, P2: boolean): event;
/**
* Listens to when two collision blocks stop colliding
* @param block_a - First block to listen to
* @param block_b - Second block to listen to
* @param P1 - Player 1 as block a
* @param P2 - Player 2 as block a
*/
function collision_exit(block_a: block, block_b: block, P1: boolean, P2: boolean): event;
/**
* Listens to when the player dies
*/
function death(): event;
/**
* Listens to when an item hits a specific number
* @param item - Item to listen to
* @param num - Number that triggers event when the item hits this
* @param multi - Whether to trigger the event multiple time
*/
function count(item: item, num: number, multi: boolean): event;
/**
* Listens to when the player reaches a specific X position
* @param x - X position where event is called
*/
function x_position(x: number): event;
/**
* Implementation of the event trigger that triggers an event
* @param event - Event(s) to be listened to (look at {@tutorial Events} for more info)
* @param extra_id - Implementation of extra ID 1
* @param extra_id2 - Implementation of extra ID 2
*/
function event(event: any[] | event_id, extra_id: number, extra_id2: number): event;
/**
* Represents gamescene (all functions in this type are made to be used with on())
* @property button_a - Returns an event when the left side is pressed
* @property button_b - Returns an event when the right side is pressed
* @property button_a_end - Returns an event when the left side is no longer pressed
* @property button_b_end - Returns an event when the right side is no longer pressed
* @property stop - Stops playing the song
*/
type gamescene = {
button_a: (...params: any[]) => any;
button_b: (...params: any[]) => any;
button_a_end: (...params: any[]) => any;
button_b_end: (...params: any[]) => any;
stop: stop;
};
/**
* Represents gamescene (all functions in this type are made to be used with on())
* @property button_a - Returns an event when the left side is pressed
* @property button_b - Returns an event when the right side is pressed
* @property button_a_end - Returns an event when the left side is no longer pressed
* @property button_b_end - Returns an event when the right side is no longer pressed
* @property stop - Stops playing the song
*/
type gamescene = {
button_a: (...params: any[]) => any;
button_b: (...params: any[]) => any;
button_a_end: (...params: any[]) => any;
button_b_end: (...params: any[]) => any;
stop: stop;
};
type events = {
NONE: number;
TINY_LANDING: number;
FEATHER_LANDING: number;
SOFT_LANDING: number;
NORMAL_LANDING: number;
HARD_LANDING: number;
HIT_HEAD: number;
ORB_TOUCHED: number;
ORB_ACTIVATED: number;
PAD_ACTIVATED: number;
GRAVITY_INVERTED: number;
GRAVITY_RESTORED: number;
NORMAL_JUMP: number;
ROBOT_BOOST_START: number;
ROBOT_BOOST_STOP: number;
UFO_JUMP: number;
SHIP_BOOST_START: number;
SHIP_BOOST_END: number;
SPIDER_TELEPORT: number;
BALL_SWITCH: number;
SWING_SWITCH: number;
WAVE_PUSH: number;
WAVE_RELEASE: number;
DASH_START: number;
DASH_STOP: number;
TELEPORTED: number;
PORTAL_NORMAL: number;
PORTAL_SHIP: number;
PORTAL_BALL: number;
PORTAL_UFO: number;
PORTAL_WAVE: number;
PORTAL_ROBOT: number;
PORTAL_SPIDER: number;
PORTAL_SWING: number;
YELLOW_ORB: number;
PINK_ORB: number;
RED_ORB: number;
GRAVITY_ORB: number;
GREEN_ORB: number;
DROP_ORB: number;
CUSTOM_ORB: number;
DASH_ORB: number;
GRAVITY_DASH_ORB: number;
SPIDER_ORB: number;
TELEPORT_ORB: number;
YELLOW_PAD: number;
PINK_PAD: number;
RED_PAD: number;
GRAVITY_PAD: number;
SPIDER_PAD: number;
PORTAL_GRAVITY_FLIP: number;
PORTAL_GRAVITY_NORMAL: number;
PORTAL_GRAVITY_INVERT: number;
PORTAL_FLIP: number;
PORTAL_UNFLIP: number;
PORTAL_NORMAL_SCALE: number;
PORTAL_MINI_SCALE: number;
PORTAL_DUAL_ON: number;
PORTAL_DUAL_OFF: number;
PORTAL_TELEPORT: number;
CHECKPOINT: number;
DESTROY_BLOCK: number;
USER_COIN: number;
PICKUP_ITEM: number;
CHECKPOINT_RESPAWN: number;
FALL_LOW: number;
FALL_MED: number;
FALL_HIGH: number;
FALL_VHIGH: number;
JUMP_PUSH: number;
JUMP_RELEASE: number;
LEFT_PUSH: number;
LEFT_RELEASE: number;
RIGHT_PUSH: number;
RIGHT_RELEASE: number;
PLAYER_REVERSED: number;
FALL_SPEED_LOW: number;
FALL_SPEED_MED: number;
FALL_SPEED_HIGH: number;
};
}
declare module "general-purpose" {
/**
* Offsets the camera by a position
* @param x - X offset of camera
* @param y - X offset of camera
* @param [duration = 0] - Duration that it takes for camera position to change
*/
function camera_offset(x: number, y: number, duration?: number): void;
/**
* Makes the camera static around a target object (group ID)
* @param group - Group storing object to be the center of camera
* @param [duration = 0] - Duration that it takes for camera to be centered around object
* @param [easing = NONE] - How smoothly the camera moves to the object
* @param [exit_instant = false] - Stops static instantly
* @param [exit_static = false] - Stops static
* @param [smooth_vel = false] - Makes transition to target adapt to current camera velocity (no easing recommended)
* @param [smooth_vel_mod = 0] - Modifier for smooth velocity
* @param [follow = false] - Makes camera change according to object movement
* @param [x_only = false] - Makes the camera only be static on X axis
* @param [x_only = false] - Makes the camera only be static on Y axis
*/
function camera_static(group: group, duration?: number, easing?: easing, exit_instant?: boolean, exit_static?: boolean, smooth_vel?: boolean, smooth_vel_mod?: number, follow?: boolean, x_only?: boolean, x_only?: boolean): void;
/**
* Makes the camera zoom in/out by a specific amount
* @param zoom_amount - Amount to zoom the camera in by
* @param [duration = 0] - How long it takes for camera to zoom in
* @param [easing = NONE] - How smoothly the camera zooms in
*/
function camera_zoom(zoom_amount: number, duration?: number, easing?: easing): void;
/**
* Toggles free mode
* @param [free_mode = true] - Whether to toggle free mode on or off
* @param [disable_grid_snap = false] - Removes default snapping to nearest grid space for the camera center
* @param [edit_cam = false] - Whether to edit camera settings
* @param [easing = 10] - Easing for camera movement (requires edit_cam to be true)
* @param [padding = 0.50] - Padding for camera movement (requires edit_cam to be true)