-
Notifications
You must be signed in to change notification settings - Fork 0
/
defns.lua
2280 lines (2109 loc) · 77.8 KB
/
defns.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Type definitions for Minetest API
---@alias SideString '"top"' | '"bottom"' | '"front"' | '"left"' | '"back"' | '"right"'
---@alias SoundSpec string
---@alias ColorSpec Color|string
---Vector-like objects that do not contain the vector metatables (ie. not
---constructed with vector.zero())
---@class SimpleVec
---@field x number
---@field y number
---@field z number
local SimpleVec = { }
---@class Vec
---@field x number
---@field y number
---@field z number
local Vec = { }
---@return Vec
function vector.zero() end
---@param v Vec
---@return Vec
function vector.copy(v) end
---@param s string
---@param init? integer
---@return Vec, integer next
function vector.from_string(s, init) end
---@param v Vec
---@return string
function vector.to_string(v) end
---@param p1 Vec
---@param p2 Vec
---@return Vec
function vector.direction(p1, p2) end
---@param p1 Vec
---@param p2 Vec
---@return number
function vector.distance(p1, p2) end
---@param v Vec
---@return number
function vector.length(v) end
---@param v Vec
---@return Vec
function vector.normalize(v) end
---@param v Vec
---@return Vec
function vector.floor(v) end
---@param v Vec
---@return Vec
function vector.round(v) end
---@param v Vec
---@param func fun(comp: number): number
function vector.apply(v, func) end
---@param v1 Vec
---@param v2 Vec
---@return Vec
function vector.dot(v1, v2) end
---@param v1 Vec
---@param v2 Vec
---@return Vec
function vector.cross(v1, v2) end
---@param v Vec
---@param x number
---@param y number
---@param z number
function vector.offset(v, x, y, z) end
---@param v Vec
---@return boolean
function vector.check(v) end
---@class Vec2
---@field x number
---@field y number
local Vec2 = { }
---@class Color
local Color = { r = 0, g = 0, b = 0, a = 0 }
---@class NoiseParams
---@field offset number
---@field scale number
---@field spread Vec
---@field seed number
---@field octaves number
---@field persistence number
local NoiseParams = { }
---@class PointedThing
---@field type '"nothing"'|'"node"'|'"object"'
---@field under? Vec
---@field above? Vec
---@field ref? AnyObjectRef
local PointedThing = { }
---@class Raycast
---@param pos1 Vec
---@param pos2 Vec
---@param objects boolean
---@param liquids boolean
---@return Raycast
function Raycast(pos1, pos2, objects, liquids) end
---@return PointedThing pointed_thing
function Raycast:next() end
---@class SecureRandom
---@return SecureRandom
function SecureRandom() end
---@param count? integer Default 1
---@return string
function SecureRandom:next_bytes(count) end
---@class Settings
---@param filename string
---@return Settings
function Settings(filename) end
---@param key string
---@return any value
function Settings:get(key) end
---@param key string
---@param default? boolean
---@return boolean|nil
function Settings:get_bool(key, default) end
---@param key string
---@return NoiseParams
function Settings:get_np_group(key) end
---@param key string
---@return table
function Settings:get_flags(key) end
---@param key string
---@param value any
function Settings:set(key, value) end
---@param key string
---@param value boolean
function Settings:set_bool(key, value) end
---@param key string
---@param value NoiseParams
function Settings:set_np_group(key, value) end
---@param key string
---@return boolean success
function Settings:remove(key) end
---@return string[]
function Settings:get_names() end
---@return boolean success
function Settings:write() end
---@return table
function Settings:to_table() end
---@class PseudoRandom
---@param seed number
---@return PseudoRandom
function PseudoRandom(seed) end
---@return integer
function PseudoRandom:next() end
---@param min integer
---@param max integer
---@return integer
function PseudoRandom:next(min, max) end
---@class PcgRandom
---@param seed any
---@param sequence any
---@return PcgRandom
function PcgRandom(seed, sequence) end
---@return integer
function PcgRandom:next() end
---@param min integer
---@param max integer
function PcgRandom:next(min, max) end
---@param min integer
---@param max integer
---@param num_trials? number Default 6
function PcgRandom:rand_normal_dist(min, max, num_trials) end
---@class PerlinNoise
---@param noiseparams table
---@return PerlinNoise
function PerlinNoise(noiseparams) end
---@param pos Vec2
---@return number
function PerlinNoise:get_2d(pos) end
---@param pos Vec
---@return number
function PerlinNoise:get_3d(pos) end
---@class PerlinNoiseMap
---@param noiseparams table
---@param size Vec|Vec2
---@return PerlinNoiseMap
function PerlinNoiseMap(noiseparams, size) end
---@param pos Vec2
---@return number[][]
function PerlinNoiseMap:get_2d_map(pos) end
---@param pos Vec
---@return number[][][]
function PerlinNoiseMap:get_3d_map(pos) end
---@param pos Vec2
---@param buffer any
---@return number[]
function PerlinNoiseMap:get_2d_map_flat(pos, buffer) end
---@param pos Vec
---@param buffer any
---@return number[]
function PerlinNoiseMap:get_3d_map_flat(pos, buffer) end
---@param pos Vec2
function PerlinNoiseMap:calc_2d_map(pos) end
---@param pos Vec
function PerlinNoiseMap:calc_3d_map(pos) end
---@param slice_offset Vec
---@param slice_size Vec
---@param buffer any
---@return number[]
function PerlinNoiseMap:get_map_slice(slice_offset, slice_size, buffer) end
---@class HttpApiTable
local HttpApiTable = { }
---@alias HttpRequestCallback fun(res: HttpRequestResultDefn)
---@param req HttpRequestDefn
---@param callback HttpRequestCallback
function HttpApiTable.fetch(req, callback) end
---@param req HttpRequestDefn
---@return any handle
function HttpApiTable.fetch_async(req) end
---@param handle any
---@return HttpRequestResultDefn
function HttpApiTable.fetch_async_get(handle) end
---@class VoxelManip
local VoxelManip = { }
---@param p1 Vec
---@param p2 Vec
---@return Vec pmin, Vec pmax
function VoxelManip:read_from_map(p1, p2) end
---@param light? boolean
function VoxelManip:write_to_map(light) end
---@param pos Vec
---@return MapNode
function VoxelManip:get_node_at(pos) end
---@param pos Vec
---@param node MapNode
function VoxelManip:set_node_at(pos, node) end
---@param buffer? number[]
---@return number[]
function VoxelManip:get_data(buffer) end
---@param data number[]
function VoxelManip:set_data(data) end
function VoxelManip:update_map() end
---@param light { day: integer, night: integer }
---@param p1? Vec
---@param p2? Vec
function VoxelManip:set_lighting(light, p1, p2) end
---@return integer[]
function VoxelManip:get_light_data() end
---@param data integer[]
function VoxelManip:set_light_data(data) end
---@param buffer? integer[]
---@return integer[]
function VoxelManip:get_param2_data(buffer) end
---@param data integer[]
function VoxelManip:set_param2_data(data) end
---@param p1? Vec
---@param p2? Vec
---@param propagate_shadow? boolean
function VoxelManip:calc_lighting(p1, p2, propagate_shadow) end
function VoxelManip:update_liquids() end
---@return boolean
function VoxelManip:was_modified() end
---@return Vec pmin, Vec pmax
function VoxelManip:get_emerged_area() end
---@class AreaStore
local AreaStore = { }
---@param id integer
---@param include_borders boolean
---@param include_data boolean
---@return nil|'true'|{ min: Vec, max: Vec, data: string } `nil` - Area not found, `true` -- Without `include_borders` and `include_data`
function AreaStore:get_area(id, include_borders, include_data) end
---@param pos Vec
---@param include_borders boolean
---@param include_data boolean
---@return { min: Vec, max: Vec, data: string }[]
function AreaStore:get_areas_for_pos(pos, include_borders, include_data) end
---@param edge1 Vec
---@param edge2 Vec
---@param accept_overlap boolean
---@param include_borders boolean
---@param include_data boolean
---@return { min: Vec, max: Vec, data: string }[]
function AreaStore:get_areas_in_area(edge1, edge2, accept_overlap, include_borders, include_data) end
---@param edge1 Vec
---@param edge2 Vec
---@param data string
---@param id? integer
function AreaStore:insert_area(edge1, edge2, data, id) end
---@param count integer
function AreaStore:reserve(count) end
---@param id integer
---@return boolean success
function AreaStore:remove_area(id) end
---@param params { enabled: boolean, block_radius: integer, limit: integer }
function AreaStore:set_cache_params(params) end
---@return string serial Binary string
function AreaStore:to_string() end
---@param filename string
function AreaStore:to_file(filename) end
---@param str string
function AreaStore:from_string(str) end
---@param filename string
function AreaStore:from_file(filename) end
---@class MetaDataRef
local MetaDataRef = { }
---@param key string
---@return boolean
function MetaDataRef:contains(key) end
---@param key string
---@return string|nil
function MetaDataRef:get(key) end
---@param key string
---@param value string Empty string removes key
function MetaDataRef:set_string(key, value) end
---@param key string
---@return string value Empty string if key not present
function MetaDataRef:get_string(key) end
---@param key string
---@param value integer
function MetaDataRef:set_int(key, value) end
---@param key string
---@return integer value 0 if key does not exist
function MetaDataRef:get_int(key) end
---@param key string
---@param value number
function MetaDataRef:set_float(key, value) end
---@param key string
---@return integer
function MetaDataRef:get_float(key) end
---@return table
function MetaDataRef:to_table() end
---@param source table|nil Clears metadata if non-table
---@return boolean success
function MetaDataRef:from_table(source) end
---@param other MetaDataRef
---@return boolean
function MetaDataRef:equals(other) end
---@class StorageRef : MetaDataRef
local StorageRef = { }
---@class NodeMetaRef : MetaDataRef
local NodeMetaRef = { }
---@return InvRef
function NodeMetaRef:get_inventory() end
---Mark specific vars as private. This will prevent them from being sent to the client. Note that the "private" status will only be remembered if an associated key-value pair exists, meaning it's best to call this when initializing all other meta (e.g. `on_construct`).
---@param name string|string[]
function NodeMetaRef:mark_as_private(name) end
---@class NodeTimerRef
local NodeTimerRef = { }
---@param timeout number
---@param elapsed number
function NodeTimerRef:set(timeout, elapsed) end
---@param timeout number
function NodeTimerRef:start(timeout) end
function NodeTimerRef:stop() end
---@return integer
function NodeTimerRef:get_timeout() end
---@return integer
function NodeTimerRef:get_elapsed() end
---@return boolean
function NodeTimerRef:is_started() end
---@class ItemStackMetaRef : MetaDataRef
local ItemStackMetaRef = {}
---@param tool_capabilities? ToolCapabilities Clears override data when nil
function ItemStackMetaRef:set_tool_capabilities(tool_capabilities) end
---@class ItemStack
local ItemStack = {}
---@return boolean
function ItemStack:is_empty() end
---@return string name (ie: 'default:stone')
function ItemStack:get_name() end
---@param item_name string
---@return boolean cleared
function ItemStack:set_name(item_name) end
---@return number
function ItemStack:get_count() end
---@param count number
---@return boolean cleared
function ItemStack:set_count(count) end
---@return number
function ItemStack:get_wear() end
---@param wear number
---@return boolean cleared
function ItemStack:set_wear(wear) end
---@return ItemStackMetaRef
function ItemStack:get_meta() end
---@return string
function ItemStack:get_description() end
---@return string
function ItemStack:get_short_description() end
function ItemStack:clear() end
function ItemStack:replace(item) end
---@return string
function ItemStack:to_string() end
---@return table
function ItemStack:to_table() end
---@return number
function ItemStack:get_stack_max() end
---@return number
function ItemStack:get_free_space() end
---@return boolean
function ItemStack:is_known() end
---@return table
function ItemStack:get_definition() end
---@return ToolCapabilities
function ItemStack:get_tool_capabilities() end
---@param amount number
function ItemStack:add_wear(amount) end
---@param item ItemStack
---@return ItemStack leftover
function ItemStack:add_item(item) end
---@param item ItemStack
---@return boolean
function ItemStack:item_fits(item) end
---@param n number
---@return ItemStack taken
function ItemStack:take_item(n) end
---@param n number
---@return ItemStack taken
function ItemStack:peek_item(n) end
---@class InvRef
local InvRef = {}
---@param listname string
---@return boolean
function InvRef:is_empty(listname) end
---@param listname string
---@return integer
function InvRef:get_size(listname) end
---@param listname string
---@param size integer
---@return boolean success
function InvRef:set_size(listname, size) end
---@param listname string
---@return integer
function InvRef:get_width(listname) end
---@param listname string
---@param width integer
function InvRef:set_width(listname, width) end
---@param listname string
---@param index integer
---@return ItemStack
function InvRef:get_stack(listname, index) end
---@param listname string
---@param index integer
---@param stack ItemStack
function InvRef:set_stack(listname, index, stack) end
---@param listname string
---@return any list TODO return type
function InvRef:get_list(listname) end
---@param listname string
---@param list any TODO type
function InvRef:set_list(listname, list) end
---@return any[] lists
function InvRef:get_lists() end
---@param lists any[]
function InvRef:set_lists(lists) end
---@param listname string
---@param stack ItemStack
---@return ItemStack leftover
function InvRef:add_item(listname, stack) end
---@param listname string
---@param stack ItemStack
---@return boolean is_room
function InvRef:room_for_item(listname, stack) end
---@param listname string
---@param stack ItemStack
---@param match_meta boolean Only compares names if unset
function InvRef:contains_item(listname, stack, match_meta) end
---Take as many items as specified from the list, returns the items that were actually removed (as an `ItemStack`) -- note that any item metadata is ignored, so attempting to remove a specific unique item this way will likely remove the wrong one -- to do that use `set_stack` with an empty `ItemStack`.
---@param listname string
---@param stack ItemStack
---@return ItemStack
function InvRef:remove_item(listname, stack) end
---returns a location compatible to `minetest.get_inventory(location)`. returns `{type="undefined"}` in case location is not known
---@return any
function InvRef:get_location() end
---@class PlayerMetaRef : MetaDataRef
local PlayerMetaRef = {}
---@class ToolGroupEntry
---@field maxlevel integer Indicates the maximum level of a node of this group that the item will be able to dig.
---@field uses integer
---@field times number[] List of digging times for different ratings of the group, for nodes of the maximum level. For example, as a Lua table, `times={2=2.00, 3=0.70}`. This would result in the item to be able to dig nodes that have a rating of `2` or `3` for this group, and unable to dig the rating `1`, which is the toughest. Unless there is a matching group that enables digging otherwise. If the result digging time is 0, a delay of 0.15 seconds is added between digging nodes; If the player releases LMB after digging, this delay is set to 0, i.e. players can more quickly click the nodes away instead of holding LMB.
local ToolGroupEntry = { }
---@class ToolCapabilities
---@field full_punch_interval number When used as a weapon, the item will do full damage if this time is spent between punches. If e.g. half the time is spent, the item will do half damage.
---@field max_drop_level integer Suggests the maximum level of node, when dug with the item, that will drop its useful item. (e.g. iron ore to drop a lump of iron). This is not automated; it is the responsibility of the node definition to implement this.
---@field groupcaps table<string, ToolGroupEntry>
---@field damage_groups table<string, number>
---@field punch_attack_uses integer | nil
local ToolCapabilities = { }
---@class ObjectRef
local ObjectRef = {}
---@return Vec
function ObjectRef:get_pos() end
---@param pos Vec
function ObjectRef:set_pos(pos) end
---@return Vec
function ObjectRef:get_velocity() end
---@param vel Vec
function ObjectRef:add_velocity(vel) end
---@param pos Vec
---@param continuous? boolean
function ObjectRef:move_to(pos, continuous) end
---@param puncher ObjectRef
---@param time_from_last_punch any time since last punch action of the puncher
---@param tool_capabilities ToolCapabilities
---@param direction any Can be nil
function ObjectRef:punch(puncher, time_from_last_punch, tool_capabilities , direction) end
---@param clicker ObjectRef
function ObjectRef:right_click(clicker) end
---@return number
function ObjectRef:get_hp() end
---@param hp number limited to the range of 0 ... 65535 (2^16 - 1)
---@param reason? string
function ObjectRef:set_hp(hp, reason) end
---@return InvRef
function ObjectRef:get_inventory() end
---@return string
function ObjectRef:get_wield_list() end
---@return number
function ObjectRef:get_wield_index() end
---@return ItemStack
function ObjectRef:get_wielded_item() end
---@param item ItemStack
---@return boolean true if successful
function ObjectRef:set_wielded_item(item) end
---@param group_table table {group1=rating, group2=rating, ...}
function ObjectRef:set_armor_groups(group_table) end
---@return table {group1=rating, group2=rating, ...}
function ObjectRef:get_armor_groups() end
---@param frame_range { x: number, y: number }
---@param frame_speed number
---@param frame_blend number
---@param frame_loop boolean
function ObjectRef:set_animation(frame_range, frame_speed, frame_blend, frame_loop) end
---@return { x: number, y: number} range, number frame_speed, number frame_blend, boolean frame_loop
function ObjectRef:get_animation() end
---@param frame_speed number
function ObjectRef:set_animation_frame_speed(frame_speed) end
---@param parent any
---@param bone? string
---@param position? Vec
---@param rotation? Vec
---@param forced_visible? boolean
function ObjectRef:set_attach(parent, bone, position, rotation, forced_visible) end
---@return any parent, string bone, Vec position, Vec rotation, boolean forced_visible
function ObjectRef:get_attach() end
---@return ObjectRef[]
function ObjectRef:get_children() end
function ObjectRef:set_detach() end
---@param bone? string
---@param position? Vec
---@param rotation? Vec
function ObjectRef:set_bone_position(bone, position, rotation) end
---@param bone string
---@return Vec position, Vec rotation
function ObjectRef:get_bone_position(bone) end
---@param property_table table
function ObjectRef:set_properties(property_table) end
---@return table
function ObjectRef:get_properties() end
---@return { text: string, color: ColorSpec, bgcolor: ColorSpec }
function ObjectRef:get_nametag_attributes() end
---@param attrs { text: string, color: ColorSpec, bgcolor: ColorSpec }
function ObjectRef:set_nametag_attributes(attrs) end
---@class LuaObjectRef : ObjectRef
local LuaObjectRef = { }
---The object is removed after returning from Lua. However the `ObjectRef`
---itself instantly becomes unusable with all further method calls having
---no effect and returning `nil`.
function LuaObjectRef:remove() end
---@param vel Vec
function LuaObjectRef:set_velocity(vel) end
---@param acc Vec
function LuaObjectRef:set_acceleration(acc) end
---@return Vec
function LuaObjectRef:get_acceleration() end
---@param rot Vec
function LuaObjectRef:set_rotation(rot) end
---@return Vec
function LuaObjectRef:get_rotation() end
---@param yaw number
function LuaObjectRef:set_yaw(yaw) end
---@return number
function LuaObjectRef:get_yaw() end
---TODO Docs
function LuaObjectRef:set_texture_mod(mod) end
---TODO Docs
function LuaObjectRef:get_texture_mod() end
---@param start_frame {x: number, y: number} The coordinate of the first frame
---@param num_frames number Total frames in the tecture
---@param framelength number Time per animated frame in seconds
---@param select_x_by_camera boolean Only for visual = `sprite`. Changes the frame `x` position according to the view direction. default: `false`.
function LuaObjectRef:set_sprite(start_frame, num_frames, framelength, select_x_by_camera) end
---@deprecated
function LuaObjectRef:get_entity_name() end
---@return any
function LuaObjectRef:get_luaentity() end
---@class PlayerObjectRef : ObjectRef
local PlayerObjectRef = { }
---@return string
function PlayerObjectRef:get_player_name() end
---@return Vec
function PlayerObjectRef:get_look_dir() end
---@return number
function PlayerObjectRef:get_look_vertical() end
---@return number
function PlayerObjectRef:get_look_horizontal() end
---@param radians number
function PlayerObjectRef:set_look_vertical(radians) end
---@param radians number
function PlayerObjectRef:set_look_horizontal(radians) end
---@return number
function PlayerObjectRef:get_breath() end
---@param value number
function PlayerObjectRef:set_breath(value) end
---@param fov number FOV value
---@param is_multiplier boolean Set to `true` if the FOV value is a multiplier. Defaults to `false`.
---@param transition_time number If defined, enables smooth FOV transition. Interpreted as the time (in seconds) to reach target FOV. If set to 0, FOV change is instantaneous. Defaults to 0.
function PlayerObjectRef:set_fov(fov, is_multiplier, transition_time) end
---@return number fov, boolean is_multiplier, number transition_time
function PlayerObjectRef:get_fov() end
---@return PlayerMetaRef
function PlayerObjectRef:get_meta() end
--- @param formspec string
function PlayerObjectRef:set_inventory_formspec(formspec) end
--- @return string
function PlayerObjectRef:get_inventory_formspec() end
--- @param formspec string
function PlayerObjectRef:set_formspec_prepend(formspec) end
--- @param formspec string
function PlayerObjectRef:get_formspec_prepend(formspec) end
--- @return { up: boolean, down: boolean, left: boolean, right: boolean, jump: boolean, aux1: boolean, sneak: boolean, dig: boolean, place: boolean, LMB: boolean, RMB: boolean, zoom: boolean }
function PlayerObjectRef:get_player_control() end
---@return number
function PlayerObjectRef:get_player_control_bits() end
--- @param override_table { speed: number, jump: number, gravity: number, sneak: boolean, sneak_glitch: boolean, new_move: boolean }
function PlayerObjectRef:set_physics_override(override_table) end
--- @return { speed: number, jump: number, gravity: number, sneak: boolean, sneak_glitch: boolean, new_move: boolean }
function PlayerObjectRef:get_physics_override() end
---@param definition HudDefn
---@return number id on success
function PlayerObjectRef:hud_add(definition) end
---@param id number
function PlayerObjectRef:hud_remove(id) end
---@param id number
---@param stat '"position"'|'"name"'|'"scale"'|'"text"'|'"number"'|'"item"'|'"dir"'
---@param value any
function PlayerObjectRef:hud_change(id, stat, value) end
---@param id number
function PlayerObjectRef:hud_get(id) end
---@param flags { hotbar: boolean, healthbar: boolean, crosshair: boolean, wielditem: boolean, breathbar: boolean, minimap: boolean, minimap_radar: boolean } If a flag is `nil`, the flag is not modified
function PlayerObjectRef:hud_set_flags(flags) end
---@return { hotbar: boolean, healthbar: boolean, crosshair: boolean, wielditem: boolean, breathbar: boolean, minimap: boolean, minimap_radar: boolean }
function PlayerObjectRef:hud_get_flags() end
---@param count number
function PlayerObjectRef:hud_set_hotbar_itemcount(count) end
---@return number
function PlayerObjectRef:hud_get_hotbar_itemcount() end
---@param texturename string
function PlayerObjectRef:hud_set_hotbar_image(texturename) end
---@return string
function PlayerObjectRef:hud_get_hotbar_image() end
---@param texturename string
function PlayerObjectRef:hud_set_hotbar_selected_image(texturename) end
---@return string
function PlayerObjectRef:hud_get_hotbar_selected_image() end
---@class MiniMapMode
---@field type '"off"'|'"surface"'|'"radar"'|'"texture"'
---@field label string
---@field size number Side length or diameter in nodes
---@field texture string
---@field scale number Only for texture type
local MiniMapMode = { }
---@param modes MiniMapMode[]
---@param selected_mode number Mode index to be selected after change (starting at 0)
function PlayerObjectRef:set_minimap_modes(modes, selected_mode) end
---@class SkyParameters
---@field base_color? ColorSpec
---@field type? string `regular` uses 0 textures, base color ignored, `skybox` uses 6 textures, base color as fog, `plain` uses 0 textures, base color as sky and fog
---@field textures? string[] A table containing up to six textures in the following order: Y+ (top), Y- (bottom), X- (west), X+ (east), Z+ (north), Z- (south).
---@field clouds? boolean
---@field sky_color? { day_sky: ColorSpec, day_horizon: ColorSpec, dawn_sky: ColorSpec, dawn_horizon: ColorSpec, night_sky: ColorSpec, night_horizon: ColorSpec, indoors: ColorSpec, fog_sun_tint: ColorSpec, fog_moon_tint: ColorSpec, fog_tint_type: string }
local SkyParameters = { }
---@param sky_parameters SkyParameters
function PlayerObjectRef:set_sky(sky_parameters) end
---@return ColorSpec base_color, string type, string[] textures, boolean clouds
function PlayerObjectRef:get_sky() end
---@class SunParameters
---@field visible? boolean
---@field texture? string
---@field tonemap? string
---@field sunrise? string
---@field sunrise_visible? boolean
---@field scale number
local SunParameters = { }
---@param sun_parameters SunParameters
function PlayerObjectRef:set_sun(sun_parameters) end
---@return SunParameters
function PlayerObjectRef:get_sun() end
---@class MoonParameters
---@field visible? boolean
---@field texture? string
---@field tonemap? string
---@field scale? number
local MoonParameters = { }
---@param moon_parameters MoonParameters
function PlayerObjectRef:set_moon(moon_parameters) end
---@return MoonParameters
function PlayerObjectRef:get_moon() end
---@class StarParameters
---@field visible? boolean
---@field count? number
---@field star_color? ColorSpec
---@field scale? number
local StarParameters = { }
---@param star_parameters StarParameters
function PlayerObjectRef:set_stars(star_parameters) end
---@return StarParameters
function PlayerObjectRef:get_stars() end
---@class CloudParameters
---@field density? number
---@field color? ColorSpec
---@field ambient? ColorSpec
---@field height? number
---@field thickness? number
---@field speed? { x: number, z: number }
local CloudParameters = { }
---@param cloud_parameters CloudParameters
function PlayerObjectRef:set_clouds(cloud_parameters) end
---@return CloudParameters
function PlayerObjectRef:get_clouds() end
---@param ratio number | nil Ratio from 0...1
function PlayerObjectRef:override_day_night_ratio(ratio) end
---@return number | nil ratio Ratio from 0...1, `nil` if not overridden
function PlayerObjectRef:get_day_night_ratio() end
---@param idle Vec2
---@param walk Vec2
---@param dig Vec2
---@param walk_while_dig Vec2
---@param frame_speed number
function PlayerObjectRef:set_local_animation(idle, walk, dig, walk_while_dig, frame_speed) end
---@return Vec2 idle, Vec2 walk, Vec2 dig, Vec2 walk_while_dig, number frame_speed
function PlayerObjectRef:get_local_animation() end
--- Arguments default to 0,0,0 if unspecified
---@param firstperson? Vec
---@param thirdperson? Vec
function PlayerObjectRef:set_eye_offset(firstperson, thirdperson) end
--- Sends a serverside loaded mapblock to the player. Resource intensive, use sparingly
---@param blockpos any
---@return boolean result false if failed
function PlayerObjectRef:send_mapblock(blockpos) end
---@alias AnyObjectRef ObjectRef|PlayerObjectRef|LuaObjectRef
-- ! Definition tables
---@class ObjectPropertiesDefn
---@field hp_max integer
---@field breath_max integer
---@field zoom_fov number
---@field eye_height number
---@field physical boolean
---@field collide_with_objects boolean
---@field collisionbox number[]
---@field selectionbox number[]
---@field visual_size Vec
---@field mesh string
---@field textures string[]
---@field colors string[]
---@field use_texture_alpha boolean
---@field spritediv Vec2
---@field initial_sprite_basepos Vec2
---@field is_visible boolean
---@field makes_footstep_sound boolean
---@field automatic_rotate number
---@field stepheight number
---@field automatic_face_movement_dir number
---@field automatic_face_movement_max_rotation_per_sec number
---@field backface_culling boolean
---@field glow number
---@field nametag string
---@field nametag_color ColorSpec
---@field nametag_bgcolor ColorSpec
---@field infotext string
---@field static_save boolean
---@field damage_texture_modifier string
---@field shaded boolean
---@field show_on_minimap boolean
local ObjectPropertiesDefn = { }
---@class CollisionInfoDefn
---@field touching_ground boolean
---@field collides boolean
---@field standing_on_object boolean
---@field collisions { type: '"node"' | '"object"', axis: '"x"' | '"y"' | '"z"', node_pos: Vec, object: ObjectRef, old_velocity: Vec, new_velocity: Vec }[]
local CollisionInfoDefn = { }
---@class EntityDefn
---@field initial_properties ObjectPropertiesDefn
---@field on_activate fun(self: any, staticdata: any, dtime_s: number): nil
---@field on_step fun(self: any, dtime: number, moveresult: CollisionInfoDefn): nil
---@field on_punch fun(self: any, puncher: AnyObjectRef, time_from_last_punch: number, tool_capabilities: ToolCapabilities, dir: any): nil
---@field on_rightclick fun(self: any, clicker: AnyObjectRef): nil
---@field get_staticdata fun(self: any): string Called sometimes; the string returned is passed to on_activate when the entity is re-activated from static state
local EntityDefn = { }
---@class ABMDefn
---@field label string Descriptive label for profiling purposes (optional). Definitions with identical labels will be listed as one.
---@field nodenames string[] Apply `action` function to these nodes. `group:groupname` can also be used here.
---@field neighbors string[] Only apply `action` to nodes that have one of, or any combination of, these neighbors. If left out or empty, any neighbor will do. `group:groupname` can also be used here.
---@field interval number Operation interval in seconds
---@field change number Chance of triggering `action` per-node per-interval is 1.0 / this value
---@field min_x integer Min height level where ABM will be processed can be used to reduce CPU usage
---@field max_y integer Max height level where ABM will be processed can be used to reduce CPU usage
---@field catch_up boolean If true, catch-up behaviour is enabled: The `chance` value is temporarily reduced when returning to an area to simulate time lost by the area being unattended. Note that the `chance` value can often be reduced to 1.
---@field action fun(pos: Vec, node: any, active_object_count: integer, active_object_count_wider: integer) Function triggered for each qualifying node. `active_object_count` is number of active objects in the node's mapblock. `active_object_count_wider` is number of active objects in the node's mapblock plus all 26 neighboring mapblocks. If any neighboring mapblocks are unloaded an estmate is calculated for them based on loaded mapblocks.
local ABMDefn = { }
---@class LBMDefn
---@field label string Descriptive label for profiling purposes (optional). Definitions with identical labels will be listed as one.
---@field name string
---@field nodenames string[] List of node names to trigger the LBM on. Also non-registered nodes will work. Groups (as of group:groupname) will work as well.
---@field run_at_every_load boolean Whether to run the LBM's action every time a block gets loaded, and not only the first time the block gets loaded after the LBM was introduced.
---@field action fun(pos: Vec, node: any): nil
local LBMDefn = { }
---@class VFTileAnimDefn
---@field type '"vertical_frames"'
---@field aspect_w integer
---@field aspect_h integer
---@field length number
local VFTileAnimDefn = { }
---@class S2DTileAnimDefn
---@field frames_w integer
---@field frames_h integer
---@field frames_length number
local S2DTileAnimDefn = { }
---@alias TileAnimDefn VFTileAnimDefn|S2DTileAnimDefn
---@class ItemDefn
---@field description string
---@field short_description string
---@field groups table
---@field inventory_image string
---@field inventory_overlay string
---@field wield_image string
---@field wield_overlay string
---@field palette string
---@field color string
---@field wield_scale Vec
---@field stack_max integer
---@field range number
---@field liquids_pointable boolean
---@field light_source integer
---@field tool_capabilities ToolCapabilities
---@field node_placement_prediction string | nil
---@field node_dig_prediction string
---@field sound table
---@field on_place fun(itemstack: ItemStack, placer: AnyObjectRef, pointed_thing: PointedThing): nil
---@field on_secondary_use fun(itemstack: ItemStack, user: AnyObjectRef|nil, pointed_thing: PointedThing): nil
---@field on_drop fun(itemstack: ItemStack, dropper: AnyObjectRef|nil, pos: Vec): nil
---@field on_use fun(itemstack: ItemStack, user: AnyObjectRef|nil, pointed_thing: PointedThing): nil
---@field after_use fun(itemstack: ItemStack, user: AnyObjectRef|nil, node: any, digparams: table): nil
local ItemDefn = { }
---@class NodeDefn
---@field drawtype string
---@field visual_scale number
---@field tiles string[]
---@field overlay_tiles string[]
---@field special_tiles string[]
---@field color ColorSpec
---@field use_texture_alpha '"opaque"'|'"clip"'|'"blend"'
---@field palette string
---@field post_effect_color ColorSpec
---@field paramtype string
---@field paramtype2 string
---@field place_param2 string|nil
---@field is_ground_content boolean
---@field sunlight_propagates boolean
---@field walkable boolean
---@field pointable boolean
---@field diggable boolean
---@field climbable boolean
---@field buildable_to boolean
---@field floodable boolean
---@field liquidtype '"none"'|'"source"'|'"flowing"'
---@field liquid_alternative_flowing string
---@field liquid_alternative_source string
---@field liquid_viscosity integer
---@field liquid_renewable boolean
---@field leveled integer
---@field leveled_max integer
---@field liquid_range integer
---@field drowning integer
---@field damage_per_second integer
---@field node_box table
---@field connects_to string[]
---@field connect_sides SideString[]
---@field mesh string
---@field selection_box table
---@field collision_box table
---@field legacy_facedir_simple boolean
---@field legacy_wallmounted boolean
---@field waving integer
---@field sounds { footstep: SoundSpec, dig: SoundSpec, dug: SoundSpec, place: SoundSpec, place_failed: SoundSpec, fall: SoundSpec }
---@field drop string | { max_items: integer, items: table[] }
---@field on_construct fun(pos: Vec): nil
---@field on_destruct fun(pos: Vec): nil
---@field after_destruct fun(pos: Vec, oldnode: any): nil
---@field on_flood fun(pos: Vec, oldnode: any, newnode: any): nil
---@field preserve_metadata fun(pos: Vec, oldnode: any, oldmeta: NodeMetaRef, drops: ItemStack[]): nil
---@field after_place_node fun(pos: Vec, placer: AnyObjectRef|nil, itemstack: ItemStack, pointed_thing: PointedThing): nil
---@field after_dig_node fun(pos: Vec, oldnode: any, oldmetadata: NodeMetaRef, digger: AnyObjectRef|nil): nil
---@field can_dig fun(pos: Vec, player: PlayerObjectRef|nil): nil
---@field on_punch fun(pos: Vec, node: any, puncher: AnyObjectRef, pointed_thing: PointedThing): nil
---@field on_rightclick fun(pos: Vec, node: any, clicker: AnyObjectRef|nil, itemstack: ItemStack, pointed_thing: PointedThing): nil
---@field on_dig fun(pos: Vec, node: any, digger: AnyObjectRef|nil): boolean
---@field on_timer fun(pos: Vec, elapsed: number): boolean
---@field on_receive_fields fun(pos: Vec, formname: string, fields: table, sender: PlayerObjectRef): nil
---@field allow_metadata_inventory_move fun(pos: Vec, from_list: any, from_index: integer, to_list: any, to_index: integer, count: integer, player: PlayerObjectRef): integer
---@field allow_metadata_inventory_put fun(pos: Vec, listname: string, index: integer, stack: ItemStack, player: PlayerObjectRef): integer
---@field allow_metadata_inventory_take fun(pos: Vec, listname: string, index: integer, stack: ItemStack, player: PlayerObjectRef): integer
---@field on_metadata_inventory_move fun(pos: Vec, from_list: any, from_index: integer, to_list: any, to_index: integer, count: integer, player: PlayerObjectRef): nil
---@field on_metadata_inventory_put fun(pos: Vec, listname: string, index: integer, stack: ItemStack, player: PlayerObjectRef): nil
---@field on_metadata_inventory_take fun(pos: Vec, listname: string, index: integer, stack: ItemStack, player: PlayerObjectRef): nil
---@field on_blast fun(pos: Vec, intensity: number)
---@field mod_origin string
local NodeDefn = { }
---@class CraftShapedDefn
---@field output string
---@field recipe string[][]
---@field replacements string[][]
local CraftShapedDefn = { }
---@class CraftShapelessDefn
---@field type '"shapeless"'
---@field output string