-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintellisense.lua
More file actions
2387 lines (2063 loc) · 108 KB
/
intellisense.lua
File metadata and controls
2387 lines (2063 loc) · 108 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
----------------------------------------
--- // Info
----------------------------------------
--[[
This file contains every Addon Lua function, callback, and type.
Simply put this file in your code workspace and you should have intellisense support (auto-completion, etc) for Addon Lua.
This extension is required: https://marketplace.visualstudio.com/items?itemName=sumneko.lua
Created by: @nameouschangey (GitHub) and @Toast732 (GitHub)
Maintained by: @Cuh4 (GitHub)
Repo: https://github.com/Cuh4/StormworksAddonLuaDocumentation
]]
----------------------------------------
--- // Changelog
----------------------------------------
--[[
Last updated for game version: v1.14.3 (The Firefighter SCBA Update)
Note that even if the above version is outdated on the latest version of this repo, it means no
functions were added, changed or removed from the game since the update.
Corrections and changes to the documentation may still be made after the game version is outdated
anyway.
Changelog available at the GitHub repo @ https://github.com/Cuh4/StormworksAddonLuaDocumentation.
]]
----------------------------------------
--- // Main
----------------------------------------
---@meta _
-------------------
-- Definitions
-------------------
--[[
A table containing most of addon lua's functions.
server.announce("Server", "Hello World")
]]
server = {}
--[[
A table containing functions that can be used for making your addon easily customizable by the user.<br>
Functions in this table must be saved in g_savedata.
g_savedata = {
example = property.checkbox("Example", false), -- defaults to false, name is "Example"
... -- anything else you want in g_savedata
}
]]
property = {}
--[[
A table containing functions that can be used for creating and manipulating matrices.<br>
local myMatrix = matrix.translation(0, 0, 0)
local x, y, z = matrix.position(myMatrix)
print(x, y, z) -- 0, 0, 0
]]
matrix = {}
--[[
A table containing debug-related functions. Only `debug.log` exists for now.<br>
debug.log("Hello World")
]]
debug = {}
--[[
A table used for saving tables, numbers, strings, and booleans across addon reloads and sessions.<br>
Only access g_savedata after `onCreate` is called, otherwise saved values won't be loaded yet.
g_savedata = {}
function onCreate(is_create)
if is_create then -- this is a new save
g_savedata.example = "Hello World"
end
print(g_savedata.example) -- "Hello World"
end
]]
g_savedata = {}
-------------------
-- Matrices
-------------------
---@class SWMatrix
---@field [1] number
---@field [2] number
---@field [3] number
---@field [4] number
---@field [5] number
---@field [6] number
---@field [7] number
---@field [8] number
---@field [9] number
---@field [10] number
---@field [11] number
---@field [12] number
---@field [13] number x
---@field [14] number y
---@field [15] number z
---@field [16] number
-- Multiplies two matrices together
---@param matrix1 SWMatrix
---@param matrix2 SWMatrix
---@return SWMatrix matrix
function matrix.multiply(matrix1, matrix2) end
-- Inverts the matrix
---@param matrix SWMatrix
---@return SWMatrix matrix
function matrix.invert(matrix) end
-- Transposes a matrix
---@param matrix SWMatrix
---@return SWMatrix matrix
function matrix.transpose(matrix) end
-- Returns an identity matrix
---@return SWMatrix matrix
function matrix.identity() end
-- Converts radians to the x axis rotation in a matrix. Doesn't rotate the orientation. Rotates the point around the center of the world (0,0,0)
---@param radians number The angle in radians you want to convert
---@return SWMatrix matrix
function matrix.rotationX(radians) end
-- Converts radians to the y axis rotation in a matrix
---@param radians number The angle in radians you want to convert
---@return SWMatrix matrix
function matrix.rotationY(radians) end
-- Converts radians to the z axis rotation in a matrix
---@param radians number The angle in radians you want to convert
---@return SWMatrix matrix
function matrix.rotationZ(radians) end
-- Returns your x,y,z points as a matrix
---@param x number
---@param y number
---@param z number
---@return SWMatrix matrix
function matrix.translation(x, y, z) end
-- Returns x,y,z when given a matrix
---@param matrix SWMatrix returns the location tuplets from the matrix provided. this is the same as MATRIX[13],MATRIX[14],MATRIX[15]
---@return number x, number y, number z
function matrix.position(matrix) end
-- Returns the distance in meters between two matrices in 3D space
---@param matrix1 SWMatrix The first matrix
---@param matrix2 SWMatrix The second matrix
---@return number dist
function matrix.distance(matrix1, matrix2) end
-- Multiplies a matrix by a vec 4.
---@param matrix1 SWMatrix The matrix to multiply
---@param x number
---@param y number
---@param z number
---@param w number
---@return number out_x, number out_y, number out_z, number out_w
function matrix.multiplyXYZW(matrix1, x, y, z, w) end
-- Returns the rotation required to face an X Z vector
---@param x number
---@param z number
---@return SWMatrix required_rotation
function matrix.rotationToFaceXZ(x, z) end
-------------------
-- Callbacks
-------------------
-- Called when all oil spills are cleared
function onClearOilSpill() end
-- called every game tick
---@param game_ticks number the number of ticks since the last onTick call (normally 1, while sleeping 400.)
function onTick(game_ticks) end
-- Called when the script is initialized (whenever creating or loading a world.)
---@param is_world_create boolean Only returns true when the world is first created.
function onCreate(is_world_create) end
-- Called when the world is exited.
function onDestroy() end
-- Called when a command is entered into chat, does not trigger if sent by server.
---@param full_message string The full message that was sent
---@param peer_id number The peer ID of the player who sent the message
---@param is_admin boolean If the player who entered the command has admin
---@param is_auth boolean If the player who entered the command is authenticated
---@param command string The command the player sent (ex: player entered "?help me", command will be "?help")
---@param ... string The rest of the args of the command, can be packed into a table with "arg = table.pack(...)" and referenced with "arg[1]", "arg[2]", ect
function onCustomCommand(full_message, peer_id, is_admin, is_auth, command, ...) end
-- Called when a message is sent to the chat, does not trigger if sent by server.
---@param peer_id number The peer ID of the player who sent the message
---@param sender_name string The name of the player who sent the message
---@param message string The message that was sent
function onChatMessage(peer_id, sender_name, message) end
-- Called when a player joins the game.
---@param steam_id number The player's Steam ID (convert to string as soon as possible to prevent loss of data)
---@param name string The player's name
---@param peer_id number The player's peer ID
---@param is_admin boolean If the player has admin
---@param is_auth boolean If the player is authenticated
function onPlayerJoin(steam_id, name, peer_id, is_admin, is_auth) end
-- Called when a player sits in a seat.
---@param peer_id number The peer ID of the player who sat in the seat
---@param vehicle_id number The vehicle ID of the vehicle which the seat belongs to
---@param seat_name string The name of the seat
function onPlayerSit(peer_id, vehicle_id, seat_name) end
-- Called when a player gets out of the seat.
---@param peer_id number The peer ID of the player who got out of the seat
---@param vehicle_id number The vehicle ID of the vehicle which the seat belongs to
---@param seat_name string The name of the seat
function onPlayerUnsit(peer_id, vehicle_id, seat_name) end
-- Called when any character (including players) sits in a seat.
---@param object_id number The object ID of the character which sat in the seat
---@param vehicle_id number The vehicle ID of the vehicle which the seat belongs to
---@param seat_name string The name of the seat
function onCharacterSit(object_id, vehicle_id, seat_name) end
-- Called when any character (including players) get out of a seat.
---@param object_id number The object ID of the character which sat in the seat
---@param vehicle_id number The vehicle ID of the vehicle which the seat belongs to
---@param seat_name string The name of the seat
function onCharacterUnsit(object_id, vehicle_id, seat_name) end
-- Called whenever any character (including players) picks up a character (including players).
---@param object_id_actor number the object id of the object which picked up the character
---@param object_id_target number the object id of who was picked up
function onCharacterPickup(object_id_actor, object_id_target) end
-- Called when any creature sits in a seat.
---@param object_id number The object ID of the creature which sat in the seat
---@param vehicle_id number The vehicle ID of the vehicle which the seat belongs to
---@param seat_name string The name of the seat
function onCreatureSit(object_id, vehicle_id, seat_name) end
-- Called when any creature gets gets out of a seat.
---@param object_id number The object ID of the character which sat in the seat
---@param vehicle_id number The vehicle ID of the vehicle which the seat belongs to
---@param seat_name string The name of the seat
function onCreatureUnsit(object_id, vehicle_id, seat_name) end
-- Called whenever any character (including players) pick up a creature.
---@param object_id_actor number the object id of the object which picked up the creature
---@param object_id_target number the object id of who was picked up
function onCreaturePickup(object_id_actor, object_id_target) end
-- Called when a character (including players) picks up an equipment item
---@param character_object_id number the object_id of the character
---@param equipment_object_id number the object_id of the equipment item
---@param EQUIPMENT_ID SWEquipmentTypeEnum the equipment_id of the item which was picked up.
function onEquipmentPickup(character_object_id, equipment_object_id, EQUIPMENT_ID) end
-- Called when a character (including players) drops an equipment item
---@param character_object_id number the object_id of the character
---@param equipment_object_id number the object_id of the equipment item
---@param EQUIPMENT_ID SWEquipmentTypeEnum the equipment_id of the item which was dropped.
function onEquipmentDrop(character_object_id, equipment_object_id, EQUIPMENT_ID) end
-- Called whenever a player respawns.
---@param peer_id number The peer ID of the player who respawned
function onPlayerRespawn(peer_id) end
-- Called when a player leaves the game.
---@param steam_id number The player's Steam ID (convert to string as soon as possible to prevent loss of data.)
---@param name string The player's name.
---@param peer_id number The player's peer ID.
---@param is_admin boolean If the player had admin.
---@param is_auth boolean If the player was authenticated.
function onPlayerLeave(steam_id, name, peer_id, is_admin, is_auth) end
-- Called when a player opens/closes the map.
---@param peer_id number The player's peer ID
---@param is_open boolean false if the map was closed, true if the map was opened
function onToggleMap(peer_id, is_open) end
-- Called when a player dies.
---@param steam_id number The player's Steam ID (convert to string as soon as possible to prevent loss of data.)
---@param name string The player's name.
---@param peer_id number The player's peer ID.
---@param is_admin boolean If the player has admin.
---@param is_auth boolean If the player is authenticated.
function onPlayerDie(steam_id, name, peer_id, is_admin, is_auth) end
-- Called when a vehicle is spawned.
---@param vehicle_id number The vehicle ID of the vehicle that was spawned.
---@param peer_id number The peer ID of the player who spawned the vehicle, -1 if spawned by the server.
---@param x number The x coordinate of the vehicle's spawn location relative to world space.
---@param y number The y coordinate of the vehicle's spawn location relative to world space.
---@param z number The z coordinate of the vehicle's spawn location relative to world space.
---@param group_cost number The cost of the group this vehicle belongs to.
---@param group_id number The ID of the group this vehicle belongs to
function onVehicleSpawn(vehicle_id, peer_id, x, y, z, group_cost, group_id) end
-- Called when a group is spawned.
---@param group_id number The group_cost ID of the group that was spawned.
---@param peer_id number The peer ID of the player who spawned the group, -1 if spawned by the server.
---@param x number The x coordinate of the group's spawn location relative to world space.
---@param y number The y coordinate of the group's spawn location relative to world space.
---@param z number The z coordinate of the group's spawn location relative to world space.
---@param group_cost number The cost of the group
function onGroupSpawn(group_id, peer_id, x, y, z, group_cost) end
-- Called when a vehicle is despawned.
---@param vehicle_id number the vehicle ID of the vehicle that was despawned.
---@param peer_id number The peer ID of the player who despawned the vehicle, -1 if despawned by the server.
function onVehicleDespawn(vehicle_id, peer_id) end
-- Called when a vehicle is loaded and is ready to be simulated.
---@param vehicle_id number The vehicle ID of the vehicle that was loaded.
function onVehicleLoad(vehicle_id) end
-- Called when a vehicle is unloaded and is no longer simulating.
---@param vehicle_id number The vehicle ID of the vehicle that was unloaded.
function onVehicleUnload(vehicle_id) end
-- Called when a vehicle is teleported or returned to the workbench.
---@param vehicle_id number The vehicle ID of the vehicle that was teleported.
---@param peer_id number The peer ID of the player who teleported the vehicle, -1 if teleported by the server.
---@param x number The x coordinate of the vehicle's spawn location relative to world space.
---@param y number The y coordinate of the vehicle's spawn location relative to world space.
---@param z number The z coordinate of the vehicle's spawn location relative to world space.
function onVehicleTeleport(vehicle_id, peer_id, x, y, z) end
-- Called when an object (character/prop/animal) has loaded and is ready to simulate.
---@param object_id number The object ID of the object that was loaded.
function onObjectLoad(object_id) end
-- Called when an object (character/prop/animal) is unloaded and is no longer simulating.
---@param object_id number The object ID of the object that was unloaded.
function onObjectUnload(object_id) end
-- Called when a button is interacted with (still triggers for locked buttons). For getting a button's current state use server.getVehicleButton() instead. Does not trigger if the button was interacted with by the server.
---@param vehicle_id number The vehicle ID of the vehicle that the button belongs to.
---@param peer_id number The peer ID of the player who interacted with the button.
---@param button_name string The name of the button that was interacted with.
---@param is_pressed boolean if the button's state is now pressed.
function onButtonPress(vehicle_id, peer_id, button_name, is_pressed) end
-- Called when a vehicle or object is spawned by a script.
---@param vehicle_or_object_id number The vehicle ID or object ID that was spawned.
---@param component_name string The display name of the component that was spawned.
---@param TYPE_STRING string The type of the component as a string ("zone", "object", "character", "vehicle", "flare", "fire", "loot", "button", "animal", "ice")
---@param addon_index number The internal index of the addon which spawned the vehicle or object.
function onSpawnAddonComponent(vehicle_or_object_id, component_name, TYPE_STRING, addon_index) end
-- Called whenever a vehicle is damaged or repaired.
---@param vehicle_id number The vehicle ID of the vehicle that was damaged or repaired.
---@param damage_amount number The amount of damage that was done to the vehicle, Negative when its repaired.
---@param voxel_x number 0,0,0 is the center of the vehicle (viewable with the move tool). Each "block" or 0.25m is a different voxel. 0,0.25,0 is one block above the start point.
---@param voxel_y number
---@param voxel_z number
---@param body_index number the body index which was damaged, 0 is the main body, useful for ignoring damage to missiles (body index can be seen via merge view in the editor, {0 = red, green, blue, yellow, magenta, cyan, orange,...})
function onVehicleDamaged(vehicle_id, damage_amount, voxel_x, voxel_y, voxel_z, body_index) end
---+ Called when a HTTP request has been returned. The callback details the request and recieved reply.
---@param port number The port the request was recieved from.
---@param request string The request that was recieved.
---@param reply string The reply that was recieved from the request.
function httpReply(port, request, reply) end
-- Called when a fire is extinguished.
---@param fire_x number The x coordinate of the fire which was extinguished in world space.
---@param fire_y number The y coordinate of the fire which was extinguished in world space.
---@param fire_z number The z coordinate of the fire which was extinguished in world space.
function onFireExtinguished(fire_x, fire_y, fire_z) end
-- Called when 5 or more trees have been detected to be on fire within a small radius.
---@param fire_objective_id number The fire objective ID of the forest fire, used to tell apart multiple forest fires.
---@param fire_x number The x coordinate of the forest fire which was detected in world space.
---@param fire_y number The y coordinate of the forest fire which was detected in world space.
---@param fire_z number The z coordinate of the forest fire which was detected in world space.
function onForestFireSpawned(fire_objective_id, fire_x, fire_y, fire_z) end
-- Called when a forest fire is extinguished.
---@param fire_objective_id number The fire objective ID of the forest fire, used to tell apart multiple forest fires.
---@param fire_x number The x coordinate of the forest fire which was extinguished in world space.
---@param fire_y number The y coordinate of the forest fire which was extinguished in world space.
---@param fire_z number The z coordinate of the forest fire which was extinguished in world space.
function onForestFireExtinguished(fire_objective_id, fire_x, fire_y, fire_z) end
-- Called when a Tornado is spawned.
---@param transform SWMatrix Where the Tornado was spawned.
function onTornado(transform) end
-- Called when a Meteor is spawned.
---@param transform SWMatrix Where the Meteor was spawned.
function onMeteor(transform, magnitude) end
-- Called when a Tsunami is spawned.
---@param transform SWMatrix Where the Tsunami was spawned.
---@param magnitude number The magnitude of the Tsunami. (0-1)
function onTsunami(transform, magnitude) end
-- Called when a Whirlpool is spawned.
---@param transform SWMatrix Where the Whirlpool was spawned.
---@param magnitude number The magnitude of the Whirlpool. (0-1)
function onWhirlpool(transform, magnitude) end
-- Called when a Volcano erupts.
---@param transform SWMatrix Where the Volcano was spawned.
function onVolcano(transform) end
-- Called when an oil spill is updated
---@param tile_x number tile_x coordinate
---@param tile_z number tile_z coordinate
---@param delta number how much the oil amount has changed since last time.
---@param total number the total amount of oil for this spill
---@param vehicle_id integer the vehicle_id which caused the oil spill to change, vehicle_id is -1 for script commands and oil tick updates.
function onOilSpill(tile_x, tile_z, delta, total, vehicle_id) end
-------------------
-- Enums
-------------------
---@alias SWObjectTypeEnum
---| 0 # none
---| 1 # character
---| 2 # crate_small
---| 3 # collectable (Not spawnable)
---| 4 # basketball
---| 5 # television
---| 6 # barrel
---| 7 # schematic (Not spawnable)
---| 8 # debris (Not spawnable)
---| 9 # chair
---| 10 # trolley_food
---| 11 # trolley_med
---| 12 # clothing (Not spawnable)
---| 13 # office_chair
---| 14 # book
---| 15 # bottle
---| 16 # fryingpan
---| 17 # mug
---| 18 # saucepan
---| 19 # stool
---| 20 # telescope
---| 21 # log
---| 22 # bin
---| 23 # book_2
---| 24 # loot
---| 25 # blue_barrel
---| 26 # buoyancy_ring
---| 27 # container
---| 28 # gas_canister
---| 29 # pallet
---| 30 # storage_bin
---| 31 # fire_extinguisher
---| 32 # trolley_tool
---| 33 # cafetiere
---| 34 # drawers_tools
---| 35 # glass
---| 36 # microwave
---| 37 # plate
---| 38 # box_closed
---| 39 # box_open
---| 40 # desk_lamp
---| 41 # eraser_board
---| 42 # folder
---| 43 # funnel
---| 44 # lamp
---| 45 # microscope
---| 46 # notebook
---| 47 # pen_marker
---| 48 # pencil
---| 49 # scales
---| 50 # science_beaker
---| 51 # science_cylinder
---| 52 # science_flask
---| 53 # tub_1
---| 54 # tub_2
---| 55 # filestack
---| 56 # barrel_toxic
---| 57 # flare
---| 58 # fire
---| 59 # animal
---| 60 # map_label (Not spawnable)
---| 61 # iceberg (Not spawnable)
---| 62 # gun_flare
---| 63 # vehicle_flare
---| 64 # ammo_shell
---| 65 # binoculars
---| 66 # C4
---| 67 # grenade
---| 68 # vehicle_flare
---| 69 # coal
---| 70 # meteorite
---| 71 # glowstick
---| 72 # creature
---| 73 # drill_rod
---| 74 # fishing_lure
---@alias SWAddonComponentDataTypeEnum
---| 0 # zone
---| 1 # object
---| 2 # character
---| 3 # vehicle
---| 4 # flare
---| 5 # fire
---| 6 # loot
---| 7 # button
---| 8 # animal
---| 9 # ice
---| 10 # cargo_zone
---@alias SWTankFluidTypeEnum
---| 0 # freshwater
---| 1 # diesel
---| 2 # jetfuel
---| 3 # air
---| 4 # exhaust
---| 5 # oil
---| 6 # seawater
---| 7 # steam
---| 8 # slurry
---| 9 # saturated slurry
---| 10 # oxygen
---| 11 # nitrogen
---| 12 # hydrogen
---@alias SWResourceTypeEnum
---| 0 # coal
---| 1 # iron
---| 2 # aluminium
---| 3 # gold
---| 4 # gold_dirt
---| 5 # uranium
---| 6 # ingot_iron
---| 7 # ingot_steel
---| 8 # ingot_aluminium
---| 9 # ingot_gold_impure
---| 10 # ingot_gold
---| 11 # ingot_uranium
---| 12 # solid_propellant
---| 13 # anchovy
---| 14 # anglerfish
---| 15 # arctic_char
---| 16 # ballan_lizardfish
---| 17 # ballan_wrasse
---| 18 # barreleye_fish
---| 19 # black_bream
---| 20 # black_dragonfish
---| 21 # clownfish
---| 22 # cod
---| 23 # dolphinfish
---| 24 # gulper_eel
---| 25 # haddock
---| 26 # hake
---| 27 # herring
---| 28 # john_dory
---| 29 # labrus
---| 30 # lanternfish
---| 31 # mackerel
---| 32 # midshipman
---| 33 # perch
---| 34 # pike
---| 35 # pinecone_fish
---| 36 # pollock
---| 37 # red_mullet
---| 38 # rockfish
---| 39 # sablefish
---| 40 # salmon
---| 41 # sardine
---| 42 # scad
---| 43 # sea_bream
---| 44 # halibut
---| 45 # sea_piranha
---| 46 # seabass
---| 47 # slimehead
---| 48 # snapper
---| 49 # gold_snapper
---| 50 # snook
---| 51 # spadefish
---| 52 # trout
---| 53 # tubeshoulders_fish
---| 54 # viperfish
---| 55 # yellowfin_tuna
---@alias SWGameSettingEnum
---| "photo_mode"
---| "map_show_players"
---| "sharks"
---| "infinite_fuel"
---| "lightning"
---| "show_name_plates"
---| "override_weather"
---| "megalodon"
---| "infinite_money"
---| "night_length"
---| "fast_travel"
---| "cleanup_vehicle"
---| "settings_menu"
---| "settings_menu_lock"
---| "rogue_mode"
---| "ceasefire"
---| "vehicle_damage"
---| "vehicle_spawning"
---| "engine_overheating"
---| "third_person_vehicle"
---| "infinite_ammo"
---| "no_clip"
---| "unlock_all_components"
---| "day_length"
---| "player_damage"
---| "map_show_vehicles"
---| "despawn_on_leave"
---| "third_person"
---| "infinite_batteries"
---| "teleport_vehicle"
---| "clear_fow"
---| "npc_damage"
---| "show_3d_waypoints"
---| "map_teleport"
---| "respawning"
---| "unlock_all_islands"
-------------------
-- Addon
-------------------
---@alias SWZoneTypeEnum
---| 0 # box
---| 1 # sphere
---| 2 # radius
---@class SWZone
---@field tags table<number, string> The tags on the zone
---@field tags_full string
---@field name string The name of the zone
---@field transform SWMatrix The location of the zone
---@field size SWZoneSize size of the zone
---@field radius number The radius of the zone
---@field type SWZoneTypeEnum The shape of the zone
---@field parent_vehicle_id number the parent's vehicle_id
---@field parent_relative_transform SWMatrix the matrix relative to the parent
---@class SWZoneSize
---@field x number The world X coordinate
---@field y number The world Y coordinate
---@field z number The world Z coordinate
---@class SWAddonData
---@field name string The name of the addon
---@field path_id string
---@field file_store string
---@field location_count number The number of locations in the addon
---@class SWLocationData
---@field name string The name of the location
---@field tile string The filename of the tile location
---@field env_spawn_count number The amount of environment spawns
---@field env_mod boolean Whether the location is an environment mod
---@field component_count number The amount of components in this location
---@class SWAddonComponentData
---@field tags_full string
---@field tags table<number, string> The tags on the component
---@field display_name string The display name of the component
---@field type SWAddonComponentDataTypeEnum The type of the component (0 = zone, 1 = object, 2 = character, 3 = vehicle, 4 = flare, 5 = fire, 6 = loot, 7 = button, 8 = animal, 9 = ice, 10 = cargo_zone)
---@field id number The ID of the component from the missions editor e.g. ID_27
---@field dynamic_object_type SWObjectTypeEnum The object type of the component (number for pan/character/pot/whatever)
---@field transform SWMatrix The position of the component
---@field vehicle_parent_component_id number
---@field character_outfit_type number The character outfit type (See Outfit type)
---@field interactable boolean
---@field creature_type SWCreatureTypeEnum
---@field animal_type SWAnimalTypeEnum
---@class SWAddonComponentSpawned
---@field tags_full string The tags as a string (ex. "tag1,tag2,tag3")
---@field tags table<number, string> The tags of the component
---@field display_name string The display name of the component
---@field type SWAddonComponentDataTypeEnum The type of the component
---@field transform SWMatrix The location of the component
---@field id number object_id/vehicle id of spawned item
---@field object_id number The object_id/main_vehicle_id, if this component is an object
---@field group_id number The object_id/group_id, if this component is a group
---@field vehicle_ids table<integer, integer> The IDs of the vehicle belonging to this component if it is a group
-- Get the internal index of an active addon (useful if you want to spawn objects from another script). Omitting the name argument will return this addon's index
---@param name string|nil The name of the addon as it appears in xml file. Not the filename
---@return number addon_index, boolean is_success
function server.getAddonIndex(name) end
---@deprecated
server.getPlaylistIndexCurrent = server.getAddonIndex
---@deprecated
server.getPlaylistIndexByName = server.getAddonIndex
-- Get the internal index of a location in the specified addon by its name (this index is local to the addon)
---@param addon_index number The index of the addon as it is found in the missions folder. There is no set order and it may not be the same next execution.
---@param name string The name of the location as it appears in the addon
---@return number location_index
function server.getLocationIndex(addon_index, name) end
-- The name of the location as it appears in the addon
---@param name string
---@return boolean is_success
function server.spawnThisAddonLocation(name) end
---@deprecated
server.spawnThisPlaylistMissionLocation = server.spawnThisAddonLocation
-- Directly spawn a location by a name from the current addon, optional matrix parameter
---@param name string the name of the location in the current addon
---@param matrix SWMatrix? optional param, leaving blank will result in it spawning at the first tile of the location type, matrix in global space.
---@return number location_index the index of the location which was spawned.
---@return boolean is_success true if it successfully spawned the location, false if it failed
function server.spawnNamedAddonLocation(name, matrix) end
-- Spawn a mission location at the given matrix
---@param matrix SWMatrix Matrix the mission location should spawn at. 0,0,0 matrix will spawn at a random location of the tile's type.
---@param addon_index number The index of the addon as it is found in the missions folder. There is no set order and it may not be the same next execution.
---@param location_index number The index of the location as it appears in the addon.
---@return SWMatrix matrix, boolean is_success
function server.spawnAddonLocation(matrix, addon_index, location_index) end
---@deprecated
server.spawnMissionLocation = server.spawnAddonLocation
-- Get the filepath of a addon
---@param addon_name string The name of the addon as it appears in the save file
---@param is_rom boolean Only true for missions that are made by the developers (or at least put in the file path "Stormworks\rom\data\missions")
---@return string path, boolean is_success
function server.getAddonPath(addon_name, is_rom) end
---@deprecated
server.getPlaylistPath = server.getAddonPath
-- Returns a list of all env mod zones
---@param tag string|nil Returns a list of all env mod zones that match the tag(s). Example: server.getZones("type=car,arctic") Returns all zones that have exactly type=car AND arctic in it's tags
---@return table<number, SWZone> ZONE_LIST
function server.getZones(tag) end
-- Returns whether the matrix is within an env mod zone that matches the display name
---@param matrix SWMatrix The matrix to check
---@param zone_display_name string The environment mod zone to test the matrix against
---@return boolean is_in_zone, boolean is_success
function server.isInZone(matrix, zone_display_name) end
-- Returns the amount of addons that are enabled on this save
---@return number count
function server.getAddonCount() end
---@deprecated
server.getPlaylistCount = server.getAddonCount
-- Returns data about the addon
---@param addon_index number The index of the addon as it is found in the missions folder. There is no set order and it may not be the same next execution. INDEX STARTS AT 0
---@return SWAddonData addon_data
function server.getAddonData(addon_index) end
---@deprecated
server.getPlaylistData = server.getAddonData
-- Returns data on a specific location in the addon
---@param addon_index number The index of the addon as it is found in the missions folder. There is no set order and it may not be the same next execution. INDEX STARTS AT 0
---@param location_index number The index of the location as it is found in the missions folder. There is no set order and it may not be the same next execution. INDEX STARTS AT 0
---@return SWLocationData location_data, boolean is_success
function server.getLocationData(addon_index, location_index) end
-- Returns data on a specific mission component. returned data includes component_id which can be used with server.spawnVehicle()
---@param addon_index number The index of the addon as it is found in the missions folder. There is no set order and it may not be the same next execution. INDEX STARTS AT 0
---@param location_index number The index of the location in the addon
---@param component_index number The index of the component in the addon
---@return SWAddonComponentData component_data, boolean is_success
function server.getLocationComponentData(addon_index, location_index, component_index) end
-- Spawns a component within an addon's misson location. This can be used to spawn vehicles, objects, NPCs, fires, etc.
---@param matrix SWMatrix The matrix the mission object should be spawned at
---@param addon_index number The index of the addon as it is found in the missions folder. There is no set order and it may not be the same next execution.
---@param location_index number The unique index of the location that the component is in
---@param component_index number The index of the component that can be read from the COMPONENT_DATA table using server.getLocationComponentData()
---@param parent_vehicle_id number? optional id of the vehicle to parent the fire or zone component to,
---@return SWAddonComponentSpawned component, boolean is_success
function server.spawnAddonComponent(matrix, addon_index, location_index, component_index, parent_vehicle_id) end
---@deprecated
server.spawnMissionComponent = server.spawnAddonComponent
-------------------
-- UI
-------------------
---@alias SWLabelTypeEnum
---| 0 # none
---| 1 # cross
---| 2 # wreckage
---| 3 # terminal
---| 4 # military
---| 5 # heritage
---| 6 # rig
---| 7 # industrial
---| 8 # hospital
---| 9 # science
---| 10 # airport
---| 11 # coastguard
---| 12 # lighthouse
---| 13 # fuel
---| 14 # fuel_sell
---| 15 # hospital ship
---| 16 # refuel_plane
---| 17 # ore
---| 18 # ingot
---| 19 # fish
---| 20 # dollar
---@alias SWPositionTypeEnum
---| 0 # fixed
---| 1 # vehicle
---| 2 # object
---@alias SWMarkerTypeEnum
---| 0 # delivery_target
---| 1 # survivor
---| 2 # object
---| 3 # waypoint
---| 4 # tutorial
---| 5 # fire
---| 6 # shark
---| 7 # ice
---| 8 # search_radius
---| 9 # flag_1
---| 10 # flag_2
---| 11 # house
---| 12 # car
---| 13 # plane
---| 14 # tank
---| 15 # heli
---| 16 # ship
---| 17 # boat
---| 18 # attack
---| 19 # defend
---@alias SWNotificationTypeEnum
---| 0 # new_mission
---| 1 # new_mission_critical
---| 2 # failed_mission
---| 3 # failed_mission_critical
---| 4 # complete_mission
---| 5 # network_connect
---| 6 # network_disconnect
---| 7 # network_info
---| 8 # chat_message
---| 9 # rewards
---| 10 # network_info_critical
---| 11 # research_complete
-- Messages player(s) using the in-game chat
---@param name string The display name of the user sending the message
---@param message string The message to send the player(s)
---@param peerID number|nil The peerID of the player you want to message. -1 messages all players. If ignored, it will message all players
function server.announce(name, message, peerID) end
-- Sends a command that can be recieved by addons using the onCustomCommand callback
-- `onCustomCommand` will receive a peer ID of `-1`, with auth and admin both provided as `true`.
---@param message string the message to send, for example, "?prefix command arg1"
function server.command(message) end
-- Displays a notification for player(s) on the right side of the screen.
---@param peerID number The peerID of the player you want to message. -1 messages all players
---@param title string The title of the notification
---@param message string The message you want to send the player(s)
---@param notificationType SWNotificationTypeEnum Changes how the notification looks. Refer to notificationTypes
function server.notify(peerID, title, message, notificationType) end
-- Gets a unique ID to be used with other UI functions. Functions similar to a vehicle ID. A UI id can be used for multiple lines and map objects but each popup with a different text or position must have it's own ID
---@return integer ui_id
function server.getMapID() end
-- Remove any UI type created with this ui_id. If you have drawn multiple lines on the map with one UI id, this command would remove all of them.
---@param peer_id number The peer id of the affected player. -1 affects all players
---@param ui_id integer The unique ui id to be removed
function server.removeMapID(peer_id, ui_id) end
-- Add a map marker for the specified peer(s). x, z represent the worldspace location of the marker, since the map is 2D a y coordinate is not required. If POSITION_TYPE is set to 1 or 2 (vehicle or object) then the marker will track the object/vehicle of object_id/vehicle_id and offset the position by parent_local_x, parent_local_z.
---@param peer_id number The peer id of the affected player. -1 affects all players
---@param ui_id integer The unique ui id to use
---@param position_type SWPositionTypeEnum Defines what type (object/vehicle) the marker should follow. Or if it should not follow anything. If the vehicle/object that object is set to follow cannot be found, this defaults to 0 meaning it becomes static, when the vehicle/object is reloacated, it reverts back to the previous value.
---@param marker_type SWMarkerTypeEnum The type of map object to use. Changes the visible icon on the map
---@param x number Refer to World Space. Overrides parent_local_x
---@param z number Refer to World Space. Overrrides parent_local_z
---@param parent_local_x number The x offset relative to the parent. Refer to World Space
---@param parent_local_z number The y offset relative to the parent. Refer to World Space
---@param vehicle_id number The vehicle to follow if POSITION_TYPE is set to 1. Set to 0 to ignore
---@param object_id number The object to follow if POSITION_TYPE is set to 2. Set to 0 to ignore
---@param label string The text that appears when mousing over the icon. Appears like a title
---@param radius number The radius of the red dashed circle. Only applies if MARKER_TYPE = 8
---@param hover_label string The text that appears when mousing over the icon. Appears like a subtitle or description
---@param r number? the amount of red, range is 0-255
---@param g number? the amount of green, range is 0-255
---@param b number? the amount of blue, range is 0-255
---@param a number? the alpha of the object, range is 0-255
function server.addMapObject(peer_id, ui_id, position_type, marker_type, x, z, parent_local_x, parent_local_z, vehicle_id, object_id, label, radius, hover_label, r, g, b, a) end
-- Removes the map objects with the specified ui_id for the specified peer(s)
---@param peer_id number The peer id of the affected player. -1 affects all players
---@param ui_id integer The unique ui id to use
function server.removeMapObject(peer_id, ui_id) end
-- Adds a map label for the specified peer(s). Map labels appear under fog of war.
---@param peer_id number The peer id of the affected player. -1 affects all players
---@param ui_id integer The unique ui id to use
---@param LABEL_TYPE SWLabelTypeEnum The type of label to use. Changes the visible icon on the map
---@param name string The text that appears on the label
---@param x number Refer to World Space
---@param z number Refer to World Space
function server.addMapLabel(peer_id, ui_id, LABEL_TYPE, name, x, z) end
-- Removes a map label with the specified ui_id for the specified peer(s)
---@param peer_id number The peer id of the affected player. -1 affects all players
---@param ui_id integer The ui id to use
function server.removeMapLabel(peer_id, ui_id) end
-- Adds a map line between two world space matrices with the specified ui_id for the specified pee(s). Custom colour defaults to red.
---@param peer_id number The peer id of the affected player. -1 affects all players
---@param ui_id integer The ui id to use
---@param start_matrix SWMatrix Line start position. worldspace
---@param end_matrix SWMatrix Line stop position
---@param width number Line width
---@param r number? the amount of red, range is 0-255
---@param g number? the amount of green, range is 0-255
---@param b number? the amount of blue, range is 0-255
---@param a number? the alpha of the line, range is 0-255
function server.addMapLine(peer_id, ui_id, start_matrix, end_matrix, width, r, g, b, a) end
-- Removes a map line with the specified ui_id for the specified peer(s)
---@param peer_id number The peer id of the affected player
---@param ui_id integer The ui id to use
function server.removeMapLine(peer_id, ui_id) end
-- Displays a tooltip-like popup either in the world. If the popup does not exist, it will be created.
---@param peer_id number The peer id of the affected player. -1 affects all players
---@param ui_id integer A unique ui_id to be used with this popup. You cannot re-use ui ids for popups, unless they have the same text and position, then they can be used for multiple players.
---@param name string ? Appears to do nothing. Can be left as an empty string: ""
---@param is_show boolean If the popup is currently being shown
---@param text string The text inside the popup. You can fit 13 characters in a line before it will wrap.
---@param x number X position of the popup. worldspace (if vehicle_parent_id or object_parent_id is specified, this will become a relative position)
---@param y number Y position of the popup. worldspace (if vehicle_parent_id or object_parent_id is specified, this will become a relative position)
---@param z number Z position of the popup. worldspace (if vehicle_parent_id or object_parent_id is specified, this will become a relative position)
---@param render_distance number The distance the popup will be viewable from in meters
---@param vehicle_parent_id number? (optional) The vehicle to attach the popup to
---@param object_parent_id number? (optional) The object to attach the popup to
function server.setPopup(peer_id, ui_id, name, is_show, text, x, y, z, render_distance, vehicle_parent_id, object_parent_id) end
-- Creates a popup that appears on the player's screen, regardless of their look direction and location in the world.
---@param peer_id number The peer id of the affected player. -1 affects all players
---@param ui_id integer A unique ui_id to be used with this popup. You cannot re-use ui ids for popups. One ui id per popup.
---@param name string ?
---@param is_show boolean If the popup is currently being shown
---@param text string The text inside the popup. You can fit 13 characters in a line before it will wrap.
---@param horizontal_offset number The offset on the horizontal axis. Ranges from -1 (left) to 1 (right)
---@param vertical_offset number The offset on the vertical axis. Ranges from -1 (Top) to 1 (Bottom)
function server.setPopupScreen(peer_id, ui_id, name, is_show, text, horizontal_offset, vertical_offset) end
-- Will remove popups that have been assigned to a player
---@param peer_id number The peer id of the affected player. -1 affects all players
---@param ui_id integer The unique ui id to use
function server.removePopup(peer_id, ui_id) end
-------------------
-- Objects
-------------------
---@class SWPlayer
---@field id number The peer ID of the player (as seen in the server player list)
---@field name string The name of the player
---@field admin boolean Whether the player is an admin
---@field auth boolean Whether the player has auth
---@field steam_id number The player's Steam ID (convert to string as soon as possible to prevent loss of data)
---@field object_id number The player's character's object ID. Note that this isnt in the in-game documentation for some reason
---@class SWObjectData object here is interchangable with "character"
---@field object_type SWObjectTypeEnum the object's type.
---@field hp number The objects's health points
---@field incapacitated boolean Whether the object is incapacitated
---@field dead boolean Whether the object is dead