-
Notifications
You must be signed in to change notification settings - Fork 0
/
debugcommands.lua
3763 lines (3183 loc) · 122 KB
/
debugcommands.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
local scrapbookprefabs = require("scrapbook_prefabs")
function d_spawnlist(list, spacing, fn)
local created = {}
spacing = spacing or 2
local num_wide = math.ceil(math.sqrt(#list))
local pt = ConsoleWorldPosition()
pt.x = pt.x - num_wide * 0.5 * spacing
pt.z = pt.z - num_wide * 0.5 * spacing
for y = 0, num_wide-1 do
for x = 0, num_wide-1 do
if list[(y*num_wide + x + 1)] then
local prefab = list[(y*num_wide + x + 1)]
local count = 1
local item_fn = nil
if type(prefab) == "table" then
count = prefab[2]
item_fn = prefab[3]
prefab = prefab[1]
end
local inst = SpawnPrefab(prefab)
if inst ~= nil then
table.insert(created, inst)
inst.Transform:SetPosition((pt + Vector3(x*spacing, 0, y*spacing)):Get())
if count > 1 then
if inst.components.stackable then
inst.components.stackable:SetStackSize(count)
end
end
if item_fn ~= nil then
item_fn(inst)
end
if fn ~= nil then
fn(inst)
end
end
end
end
end
return created
end
function d_playeritems()
local items = {}
for prefab, recipe in pairs(AllRecipes) do
if recipe.builder_tag and recipe.placer == nil and prefab:find("_builder") == nil then
items[recipe.builder_tag] = items[recipe.builder_tag] or {}
table.insert(items[recipe.builder_tag], prefab)
end
end
local items_sorted = {}
for tag, prefabs in pairs(items) do
table.insert(items_sorted, tag)
end
table.sort(items_sorted)
local tospawn = {}
for _, tag in ipairs(items_sorted) do
table.sort(items[tag])
for _, prefab in ipairs(items[tag]) do
if Prefabs[prefab] ~= nil then
table.insert(tospawn, prefab)
end
end
end
d_spawnlist(tospawn, 1.5)
end
function d_allmutators()
c_give("mutator_warrior")
c_give("mutator_dropper")
c_give("mutator_hider")
c_give("mutator_spitter")
c_give("mutator_moon")
c_give("mutator_water")
end
function d_allcircuits()
local module_defs = require("wx78_moduledefs").module_definitions
local pt = ConsoleWorldPosition()
local spacing, num_wide = 2, math.ceil(math.sqrt(#module_defs))
for y = 0, num_wide - 1 do
for x = 0, num_wide - 1 do
local def = module_defs[(y*num_wide) + x + 1]
local circuit = SpawnPrefab("wx78module_"..def.name)
if circuit ~= nil then
local spacing_vec = Vector3(x * spacing, 0, y * spacing)
circuit.Transform:SetPosition((pt + spacing_vec):Get())
end
end
end
end
function d_allheavy()
local heavy_objs = {
"cavein_boulder",
"sunkenchest",
"sculpture_knighthead",
"glassspike",
"moon_altar_idol",
"oceantreenut",
"shell_cluster",
"potato_oversized",
"chesspiece_knight_stone",
"chesspiece_knight_marble",
"chesspiece_knight_moonglass",
"potatosack"
}
local x,y,z = ConsoleWorldPosition():Get()
local start_x = x
for i,v in ipairs(heavy_objs) do
local obj = SpawnPrefab(v)
obj.Transform:SetPosition(x,y,z)
x = x + 2.5
if i == 6 then
z = z + 2.5
x = start_x
end
end
end
function d_spiders()
local spiders = {
"spider",
"spider_warrior",
"spider_dropper",
"spider_hider",
"spider_spitter",
"spider_moon",
"spider_healer",
}
for i,v in ipairs(spiders) do
local spider = c_spawn(v)
spider.components.follower:SetLeader(ThePlayer)
end
c_give("spider_water")
end
function d_particles()
local emittingfx = {
"cane_candy_fx",
"cane_harlequin_fx",
"cane_victorian_fx",
"eyeflame",
"lighterfire_haunteddoll",
"lighterfire",
"lunar_goop_cloud_fx",
"thurible_smoke",
"torchfire",
"torchfire_barber",
"torchfire_carrat",
"torchfire_nautical",
"torchfire_pillar",
"torchfire_pronged",
"torchfire_rag",
"torchfire_shadow",
"torchfire_spooky",
"torchfire_yotrpillowfight",
-- Particles below need special handling to function.
--"frostbreath",
--"lunarrift_crystal_spawn_fx",
--"nightsword_curve_fx",
--"nightsword_lightsbane_fx",
--"nightsword_sharp_fx",
--"nightsword_wizard_fx",
--"reviver_cupid_beat_fx",
--"reviver_cupid_glow_fx",
}
local overridespeed = { -- Some particles want speed to emit.
cane_harlequin_fx = PI2 * FRAMES,
cane_victorian_fx = PI2 * FRAMES,
}
local created = d_spawnlist(emittingfx, 6)
local r = 1.5
for _, v in ipairs(created) do
v._d_pos = v:GetPosition()
v._d_theta = 0
v.persists = false
local labeler = c_spawn("razor")
labeler.Transform:SetPosition(v._d_pos:Get())
labeler.persists = false
labeler.AnimState:SetScale(0, 0)
local label = labeler.entity:AddLabel()
label:SetFontSize(12)
label:SetFont(BODYTEXTFONT)
label:SetWorldOffset(0, 0, 0)
label:SetText(v.prefab)
label:SetColour(1, 1, 1)
label:Enable(true)
v:DoPeriodicTask(FRAMES, function()
v._d_theta = v._d_theta + (overridespeed[v.prefab] or PI * 0.5 * FRAMES)
v.Transform:SetPosition(v._d_pos.x + r * math.cos(v._d_theta), 0, v._d_pos.z + r * math.sin(v._d_theta))
end)
end
end
function d_decodedata(path)
print("DECODING",path)
TheSim:GetPersistentString(path, function(load_success, str)
if load_success then
print("LOADED...")
TheSim:SetPersistentString(path.."_decoded", str, false, function()
print("SAVED!")
end)
else
print("ERROR LOADING FILE! (wrong path?)")
end
end)
end
function d_riftspawns()
c_announce("Rift open, 10s for spawning..")
if TheWorld:HasTag("cave") then
TheWorld:PushEvent("shadowrift_opened")
else
TheWorld:PushEvent("lunarrift_opened")
end
TheWorld:DoTaskInTime(10, function()
c_announce("Rifts Spawning..")
for i = 1, 200 do
TheWorld.components.riftspawner:SpawnRift()
end
TheWorld.components.riftspawner:DebugHighlightRifts()
end)
end
function d_lunarrift()
local riftspawner = TheWorld.components.riftspawner
riftspawner:EnableLunarRifts()
local pos = ConsoleWorldPosition()
local x, y, z = TheWorld.Map:GetTileCenterPoint(pos:Get())
pos.x, pos.y, pos.z = x, y, z
riftspawner:SpawnRift(pos)
end
function d_shadowrift()
local riftspawner = TheWorld.components.riftspawner
riftspawner:EnableShadowRifts()
local pos = ConsoleWorldPosition()
local x, y, z = TheWorld.Map:GetTileCenterPoint(pos:Get())
pos.x, pos.y, pos.z = x, y, z
riftspawner:SpawnRift(pos)
end
function d_oceanarena()
local sharkboimanager = TheWorld.components.sharkboimanager
if sharkboimanager == nil then
c_announce("Missing sharkboimanager component in TheWorld!")
return
end
sharkboimanager.TEMP_DEBUG_RATE = true
sharkboimanager:FindAndPlaceOceanArenaOverTime()
end
local TELEPORTBOAT_ITEM_MUST_TAGS = {"_inventoryitem",}
local TELEPORTBOAT_ITEM_CANT_TAGS = {"FX", "NOCLICK", "DECOR", "INLIMBO",}
local TELEPORTBOAT_BLOCKER_CANT_TAGS = {"FX", "NOCLICK", "DECOR", "INLIMBO", "_inventoryitem",}
function d_teleportboat(x, y, z)
local player = ConsoleCommandPlayer()
if not player then
c_announce("Not playing as a character.")
return
end
local boat = player:GetCurrentPlatform()
if boat == nil or not boat:HasTag("boat") then
c_announce("Not on a boat.")
return
end
if x == nil then
x, y, z = ConsoleWorldPosition():Get()--TheWorld.Map:GetTileCenterPoint(ConsoleWorldPosition():Get())
end
local boatradius = boat:GetSafePhysicsRadius()
local blocked_ents = TheSim:FindEntities(x, y, z, boatradius + MAX_PHYSICS_RADIUS, nil, TELEPORTBOAT_BLOCKER_CANT_TAGS) -- NOTES(JBK): Add another MAX_PHYSICS_RADIUS for the other entity.
if blocked_ents[1] then
c_announce(string.format("Exit is blocked by %s", tostring(blocked_ents[1])))
return
end
local item_ents = TheSim:FindEntities(x, y, z, boatradius, TELEPORTBOAT_ITEM_MUST_TAGS, TELEPORTBOAT_ITEM_CANT_TAGS)
boat.Physics:Teleport(x, y, z)
if boat.boat_item_collision then
-- NOTES(JBK): This must also teleport or it will fling items off of it in a comical fashion from the physics constraint it has.
boat.boat_item_collision.Physics:Teleport(x, y, z)
end
for _, ent in ipairs(item_ents) do
ent.components.inventoryitem:SetLanded(false, true)
end
local walkableplatform = boat.components.walkableplatform
if walkableplatform ~= nil then
local players = walkableplatform:GetPlayersOnPlatform()
for player_on_platform in pairs(players_on_platform) do
player_on_platform:SnapCamera()
end
end
end
function d_breakropebridges(delaytime)
delaytime = type(delaytime) == "number" and delaytime or nil
local ropebridgemanager = TheWorld.components.ropebridgemanager
if not ropebridgemanager then
return
end
local _map = TheWorld.Map
local breakdata
if delaytime then
breakdata = {
fxtime = delaytime,
}
breakdata.shaketime = breakdata.fxtime - 1
breakdata.destroytime = breakdata.fxtime + 70 * FRAMES
end
for i, _ in pairs(ropebridgemanager.duration_grid.grid) do
local tile_x, tile_y = ropebridgemanager.duration_grid:GetXYFromIndex(i)
local x, y, z = _map:GetTileCenterPoint(tile_x, tile_y)
if delaytime then
ropebridgemanager:QueueDestroyForRopeBridgeAtPoint(x, y, z, breakdata)
else
ropebridgemanager:DestroyRopeBridgeAtPoint(x, y, z)
end
end
end
function d_rabbitking(kind)
local player = ConsoleCommandPlayer()
if not (player and TheWorld.ismastersim) then
return
end
local rabbitkingmanager = TheWorld.components.rabbitkingmanager
if not rabbitkingmanager then
return
end
if kind then
if type(kind) == "string" then
kind = kind:gsub("rabbitking", ""):gsub("_", "")
if Prefabs["rabbitking_" .. kind] == nil then
c_announce("Rabbit King kind is invalid: " .. kind)
kind = nil
end
else
kind = nil
end
end
local success, reason = rabbitkingmanager:CreateRabbitKingForPlayer(player, nil, kind)
if not success then
c_announce("Failed to create Rabbit King: " .. tostring(reason))
end
end
function d_resetskilltree()
local player = ConsoleCommandPlayer()
if not (player and TheWorld.ismastersim) then
return
end
local skilltreeupdater = player.components.skilltreeupdater
local skilldefs = require("prefabs/skilltree_defs").SKILLTREE_DEFS[player.prefab]
if skilldefs ~= nil then
for skill, data in pairs(skilldefs) do
skilltreeupdater:DeactivateSkill(skill)
end
end
skilltreeupdater:AddSkillXP(9999999)
end
function d_reloadskilltreedefs()
require("prefabs/skilltree_defs").DEBUG_REBUILD()
if ThePlayer ~= nil and ThePlayer.HUD ~= nil then
ThePlayer.HUD:OpenPlayerInfoScreen()
end
end
function d_printskilltreestringsforcharacter(character)
character = character or ConsoleCommandPlayer().prefab
local strings = STRINGS.SKILLTREE[string.upper(character)]
local skilldefs = require("prefabs/skilltree_defs").SKILLTREE_DEFS[character]
local str = ""
for name, data in orderedPairs(skilldefs) do
local uppercase_name = string.upper(name)
if data.lock_open == nil and strings[uppercase_name.."_TITLE"] == nil then
str = string.format('%s%s_TITLE = "%s",\n', str, uppercase_name, strings[uppercase_name.."_TITLE"] or "TODO")
end
if strings[uppercase_name.."_DESC"] == nil then
str = string.format('%s%s_DESC = "%s",\n', str, uppercase_name, strings[uppercase_name.."_DESC"] or "TODO")
end
end
print("\n\n"..str)
end
function d_togglelunarhail()
local riftspawner = TheWorld.components.riftspawner
if not riftspawner:GetLunarRiftsEnabled() then
riftspawner:EnableLunarRifts()
end
if not riftspawner:IsLunarPortalActive() then
riftspawner:OnRiftTimerDone()
end
TheWorld.net.components.weather:LongUpdate(TUNING.LUNARHAIL_EVENT_COOLDOWN)
end
function d_allsongs()
c_give("battlesong_durability")
c_give("battlesong_healthgain")
c_give("battlesong_sanitygain")
c_give("battlesong_sanityaura")
c_give("battlesong_fireresistance")
c_give("battlesong_instant_taunt")
c_give("battlesong_instant_panic")
end
function d_allstscostumes()
c_give("mask_dollhat")
c_give("mask_dollbrokenhat")
c_give("mask_dollrepairedhat")
c_give("costume_doll_body")
c_give("mask_blacksmithhat")
c_give("costume_blacksmith_body")
c_give("mask_mirrorhat")
c_give("costume_mirror_body")
c_give("mask_queenhat")
c_give("costume_queen_body")
c_give("mask_kinghat")
c_give("costume_king_body")
c_give("mask_treehat")
c_give("costume_tree_body")
c_give("mask_foolhat")
c_give("costume_fool_body")
end
function d_domesticatedbeefalo(tendency, saddle)
local beef = c_spawn('beefalo')
beef.components.domesticatable:DeltaDomestication(1)
beef.components.domesticatable:DeltaObedience(0.5)
beef.components.domesticatable:DeltaTendency(TENDENCY[tendency] or TENDENCY.DEFAULT, 1)
beef:SetTendency()
beef.components.domesticatable:BecomeDomesticated()
beef.components.rideable:SetSaddle(nil, SpawnPrefab(saddle or "saddle_basic"))
end
function d_domestication(domestication, obedience)
if c_sel().components.domesticatable == nil then
print("Selected ent not domesticatable")
end
if domestication ~= nil then
c_sel().components.domesticatable:DeltaDomestication(domestication - c_sel().components.domesticatable:GetDomestication())
end
if obedience ~= nil then
c_sel().components.domesticatable:DeltaObedience(obedience - c_sel().components.domesticatable:GetObedience())
end
end
function d_testwalls()
local walls = {
"stone",
"wood",
"hay",
"ruins",
"moonrock",
}
local sx,sy,sz = ConsoleCommandPlayer().Transform:GetWorldPosition()
for i,mat in ipairs(walls) do
for j = 0,4 do
local wall = SpawnPrefab("wall_"..mat)
wall.Transform:SetPosition(sx + (i*6), sy, sz + j)
wall.components.health:SetPercent(j*0.25)
end
for j = 5,15 do
local wall = SpawnPrefab("wall_"..mat)
wall.Transform:SetPosition(sx + (i*6), sy, sz + j)
wall.components.health:SetPercent(j <= 11 and 1 or 0.5)
end
end
end
function d_testruins()
ConsoleCommandPlayer().components.builder:UnlockRecipesForTech({SCIENCE = 2, MAGIC = 2})
c_give("log", 20)
c_give("flint", 20)
c_give("twigs", 20)
c_give("cutgrass", 20)
c_give("lightbulb", 5)
c_give("healingsalve", 5)
c_give("batbat")
c_give("icestaff")
c_give("firestaff")
c_give("tentaclespike")
c_give("slurtlehat")
c_give("armorwood")
c_give("minerhat")
c_give("lantern")
c_give("backpack")
end
function d_combatgear()
c_give("armorwood")
c_give("footballhat")
c_give("spear")
end
function d_teststate(state)
c_sel().sg:GoToState(state)
end
function d_anim(animname, loop)
if GetDebugEntity() then
GetDebugEntity().AnimState:PlayAnimation(animname, loop or false)
else
print("No DebugEntity selected")
end
end
function d_light(c1, c2, c3)
TheSim:SetAmbientColour(c1, c2 or c1, c3 or c1)
end
local COMBAT_TAGS = {"_combat"}
function d_combatsimulator(prefab, count, force)
count = count or 1
local x,y,z = ConsoleWorldPosition():Get()
local MakeBattle = nil
MakeBattle = function()
local creature = DebugSpawn(prefab)
creature:ListenForEvent("onremove", MakeBattle)
creature.Transform:SetPosition(x,y,z)
if creature.components.knownlocations then
creature.components.knownlocations:RememberLocation("home", {x=x,y=y,z=z})
end
if force then
local target = FindEntity(creature, 20, nil, COMBAT_TAGS)
if target then
creature.components.combat:SetTarget(target)
end
creature:ListenForEvent("droppedtarget", function()
local target = FindEntity(creature, 20, nil, COMBAT_TAGS)
if target then
creature.components.combat:SetTarget(target)
end
end)
end
end
for i=1,count do
MakeBattle()
end
end
function d_spawn_ds(prefab, scenario)
local inst = c_spawn(prefab)
if not inst then
print("Need to select an entity to apply the scenario to.")
return
end
if inst.components.scenariorunner then
inst.components.scenariorunner:ClearScenario()
end
-- force reload the script -- this is for testing after all!
package.loaded["scenarios/"..scenario] = nil
inst:AddComponent("scenariorunner")
inst.components.scenariorunner:SetScript(scenario)
inst.components.scenariorunner:Run()
end
---------------------------------------------------
------------ skins functions --------------------
---------------------------------------------------
--For testing legacy skin DLC popup
--AddNewSkinDLCEntitlement("pack_oni_gift") MakeSkinDLCPopup()
local TEST_ITEM_NAME = "birdcage_pirate"
function d_test_thank_you(param)
local ThankYouPopup = require "screens/thankyoupopup"
local SkinGifts = require("skin_gifts")
TheFrontEnd:PushScreen(ThankYouPopup({{ item = param or TEST_ITEM_NAME, item_id = 0, gifttype = SkinGifts.types[param or TEST_ITEM_NAME] or "DEFAULT" }}))
end
function d_test_skins_popup(param)
local SkinsItemPopUp = require "screens/skinsitempopup"
TheFrontEnd:PushScreen( SkinsItemPopUp(param or TEST_ITEM_NAME, "Peter", {1.0, 0.2, 0.6, 1.0}) )
end
function d_test_skins_announce(param)
Networking_SkinAnnouncement("Peter", {1.0, 0.2, 0.6, 1.0}, param or TEST_ITEM_NAME)
end
function d_test_skins_gift(param)
local GiftItemPopUp = require "screens/giftitempopup"
TheFrontEnd:PushScreen( GiftItemPopUp(ThePlayer, { param or TEST_ITEM_NAME }, { 0 }) )
end
function d_print_skin_info()
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
local a = {
"campfire_cabin",
"armor_wood_roman",
"spear_northern",
"pickaxe_northern"
}
for _,v in pairs(a) do
print( GetSkinName(v), GetSkinUsableOnString(v) )
end
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
end
function d_skin_mode(mode)
ConsoleCommandPlayer().components.skinner:SetSkinMode(mode)
end
function d_skin_name(name)
ConsoleCommandPlayer().components.skinner:SetSkinName(name)
end
function d_clothing(name)
ConsoleCommandPlayer().components.skinner:SetClothing(name)
end
function d_clothing_clear(type)
ConsoleCommandPlayer().components.skinner:ClearClothing(type)
end
function d_cycle_clothing()
local skinslist = TheInventory:GetFullInventory()
local idx = 1
local task = nil
ConsoleCommandPlayer().cycle_clothing_task = ConsoleCommandPlayer():DoPeriodicTask(10,
function()
local type, name = GetTypeForItem(skinslist[idx].item_type)
--print("showing clothing idx ", idx, name, type, #skinslist)
if (type ~= "base" and type ~= "item") then
c_clothing(name)
end
if idx < #skinslist then
idx = idx + 1
else
print("Ending cycle")
ConsoleCommandPlayer().cycle_clothing_task:Cancel()
end
end)
end
function d_sinkhole()
c_spawn("antlion_sinkhole"):PushEvent("startcollapse")
end
function d_stalkersetup()
local mound = c_spawn("fossil_stalker")
--mound.components.workable:SetWorkLeft(mound.components.workable.maxwork - 1)
for i = 1, (mound.components.workable.maxwork - 1) do
mound.form = 1
mound.components.repairable.onrepaired(mound)
end
c_give "shadowheart"
c_give "atrium_key"
end
function d_resetruins()
TheWorld:PushEvent("resetruins")
end
-- Get the widget selected by the debug widget editor (WidgetDebug).
-- Try d_getwidget():ScaleTo(3,1,.7)
function d_getwidget()
return TheFrontEnd.widget_editor.debug_widget_target
end
function d_halloween()
local spacing = 2
local num_wide = math.ceil(math.sqrt(NUM_TRINKETS))
for y = 0, num_wide-1 do
for x = 0, num_wide-1 do
local inst = SpawnPrefab("trinket_"..(y*num_wide + x + 1))
if inst ~= nil then
print(x*spacing, y*spacing)
inst.Transform:SetPosition((ConsoleWorldPosition() + Vector3(x*spacing, 0, y*spacing)):Get())
end
end
end
local candy_wide = math.ceil(math.sqrt(NUM_HALLOWEENCANDY))
for y = 0, candy_wide-1 do
for x = 0, candy_wide-1 do
local inst = SpawnPrefab("halloweencandy_"..(y*candy_wide + x + 1))
if inst ~= nil then
print(x*spacing, y*spacing)
inst.Transform:SetPosition((ConsoleWorldPosition() + Vector3((x + num_wide)*spacing, 0, (y+num_wide)*spacing)):Get())
end
end
end
end
function d_potions()
local all_potions = {"halloweenpotion_bravery_small", "halloweenpotion_bravery_large", "halloweenpotion_health_small", "halloweenpotion_health_large",
"halloweenpotion_sanity_small", "halloweenpotion_sanity_large", "halloweenpotion_embers", "halloweenpotion_sparks", "livingtree_root"}
local spacing = 2
local num_wide = math.ceil(math.sqrt(#all_potions))
for y = 0, num_wide-1 do
for x = 0, num_wide-1 do
local inst = SpawnPrefab(all_potions[(y*num_wide + x + 1)])
if inst ~= nil then
inst.Transform:SetPosition((ConsoleWorldPosition() + Vector3(x*spacing, 0, y*spacing)):Get())
end
end
end
end
function d_weirdfloaters()
local weird_float_items =
{
"abigail flower", "axe", "batbat", "blowdart_fire", "blowdart_pipe", "blowdart_sleep",
"blowdart_walrus", "blowdart_yellow", "boomerang", "brush", "bugnet", "cane",
"firestaff", "fishingrod", "glasscutter", "goldenaxe", "goldenpickaxe",
"goldenshovel", "grass_umbrella", "greenstaff", "hambat", "hammer", "houndstooth",
"houndwhistle", "icestaff", "lucy", "miniflare", "moonglassaxe", "multitool_axe_pickaxe",
"nightstick", "nightsword", "opalstaff", "orangestaff", "panflute", "perdfan",
"pickaxe", "pitchfork", "razor", "redlantern", "shovel", "spear",
"spear_wathgrithr", "staff_tornado", "telestaff", "tentaclespike", "trap", "umbrella",
"yellowstaff", "yotp_food3",
}
local spacing = 2
local num_wide = math.ceil(math.sqrt(#weird_float_items))
for y = 0, num_wide - 1 do
for x = 0, num_wide - 1 do
local inst = SpawnPrefab(weird_float_items[y*num_wide + x + 1])
if inst ~= nil then
inst.Transform:SetPosition((ConsoleWorldPosition() + Vector3(x*spacing, 0, y*spacing)):Get())
end
end
end
end
function d_wintersfeast()
local all_items = GetAllWinterOrnamentPrefabs()
local spacing = 2
local num_wide = math.ceil(math.sqrt(#all_items))
for y = 0, num_wide-1 do
for x = 0, num_wide-1 do
local inst = SpawnPrefab(all_items[(y*num_wide + x + 1)])
if inst ~= nil then
inst.Transform:SetPosition((ConsoleWorldPosition() + Vector3(x*spacing, 0, y*spacing)):Get())
end
end
end
end
function d_wintersfood()
local spacing = 2
local num_wide = math.ceil(math.sqrt(NUM_WINTERFOOD))
for y = 0, num_wide-1 do
for x = 0, num_wide-1 do
local inst = SpawnPrefab("winter_food"..(y*num_wide + x + 1))
if inst ~= nil then
inst.Transform:SetPosition((ConsoleWorldPosition() + Vector3(x*spacing, 0, y*spacing)):Get())
end
end
end
end
function d_madsciencemats()
c_mat("halloween_experiment_bravery")
c_mat("halloween_experiment_health")
c_mat("halloween_experiment_hunger")
c_mat("halloween_experiment_sanity")
c_mat("halloween_experiment_volatile")
c_mat("halloween_experiment_root")
end
function d_showalleventservers()
TheFrontEnd._showalleventservers = not TheFrontEnd._showalleventservers
end
function d_lavaarena_skip()
TheWorld:PushEvent("ms_lavaarena_endofstage", {reason="debug triggered"})
end
function d_lavaarena_speech(dialog, banter_line)
local is_banter = string.find(string.upper(dialog), "BANTER", 1) ~= nil
dialog = STRINGS[string.upper(dialog)]
if dialog ~= nil then
if is_banter then
dialog = { dialog[banter_line or math.random(#dialog)] }
end
local lines = {}
for i,v in ipairs(dialog) do
table.insert(lines, {message=v, duration=3.5, noanim=true})
end
local target = TheWorld.components.lavaarenaevent:GetBoarlord()
if target then
target:PushEvent("lavaarena_talk", {text=lines})
end
end
end
function d_unlockallachievements()
local achievements = {}
for k, _ in pairs(EventAchievements:GetActiveAchievementsIdList()) do
table.insert(achievements, k)
end
TheItems:ReportEventProgress(json.encode_compliant(
{
WorldID = "dev_"..tostring(math.random(9999999))..tostring(math.random(9999999)),
Teams =
{
{
Won=true,
Points=5,
PlayerStats=
{
{KU = TheNet:GetUserID(), PlaytimeMs = 100000, Custom = { UnlockAchievements = achievements }},
}
},
}
}), function(ku_tbl, success) print( "Report event:", success) dumptable(ku_tbl) end )
end
function d_unlockfoodachievements()
local achievements = {
"food_001", "food_002", "food_003", "food_004", "food_005", "food_006", "food_007", "food_008", "food_009",
"food_010", "food_011", "food_012", "food_013", "food_014", "food_015", "food_016", "food_017", "food_018", "food_019",
"food_020", "food_021", "food_022", "food_023", "food_024", "food_025", "food_026", "food_027", "food_028", "food_029",
"food_030", "food_031", "food_032", "food_033", "food_034", "food_035", "food_036", "food_037", "food_038", "food_039",
"food_040", "food_041", "food_042", "food_043", "food_044", "food_045", "food_046", "food_047", "food_048", "food_049",
"food_050", "food_051", "food_052", "food_053", "food_054", "food_055", "food_056", "food_057", "food_058", "food_059",
"food_060", "food_061", "food_062", "food_063", "food_064", "food_065", "food_066", "food_067", "food_068", "food_069",
"food_syrup",
}
TheItems:ReportEventProgress(json.encode_compliant(
{
WorldID = "dev_"..tostring(math.random(9999999))..tostring(math.random(9999999)),
Teams =
{
{
Won=true,
Points=5,
PlayerStats=
{
{KU = TheNet:GetUserID(), PlaytimeMs = 1000, Custom = { UnlockAchievements = achievements }},
}
},
}
}), function(ku_tbl, success) print( "Report event:", success) dumptable(ku_tbl) end )
end
function d_reportevent(other_ku)
TheItems:ReportEventProgress(json.encode_compliant(
{
WorldID = "dev_"..tostring(math.random(9999999))..tostring(math.random(9999999)),
Teams =
{
{
Won=true,
Points=5,
PlayerStats=
{
{KU = TheNet:GetUserID(), PlaytimeMs = 100000, Custom = { UnlockAchievements = {"scotttestdaily_d1", "wintime_30"} }},
--{KU = other_ku or "KU_test", PlaytimeMs = 60000}
}
},
--{
-- Won=false,
-- Points=2,
-- PlayerStats=
-- {
-- {KU = "KU_test2", PlaytimeMs = 6000}
-- }
--}
}
}), function(ku_tbl, success) print( "Report event:", success) dumptable(ku_tbl) end )
end
function d_ground(ground, pt)
ground = ground == nil and WORLD_TILES.QUAGMIRE_SOIL or
type(ground) == "string" and WORLD_TILES[string.upper(ground)]
or ground
pt = pt or ConsoleWorldPosition()
local x, y = TheWorld.Map:GetTileCoordsAtPoint(pt:Get())
TheWorld.Map:SetTile(x, y, ground)
end
function d_portalfx()
TheWorld:PushEvent("ms_newplayercharacterspawned", { player = ThePlayer})
end
function d_walls(width, height)
width = math.floor(width or 10)
height = math.floor(height or width)
local pt = ConsoleWorldPosition()
local left = math.floor(pt.x - width/2)
local top = math.floor(pt.z + height/2)
for i = 1, height do
SpawnPrefab("wall_wood").Transform:SetPosition(left + 1, 0, top - i)
SpawnPrefab("wall_wood").Transform:SetPosition(left + width, 0, top - i)
end
for i = 2, width-1 do
SpawnPrefab("wall_wood").Transform:SetPosition(left + i, 0, top-1)
SpawnPrefab("wall_wood").Transform:SetPosition(left + i, 0, top - height)
end
end
-- hidingspot = c_select() kitcoon = SpawnPrefab("kitcoon_deciduous") if not kitcoon.components.hideandseekhider:GoHide(hidingspot, 0) then kitcoon:Remove() end kitcoon = nil hidingspot = nil
function d_hidekitcoon()
local hidingspot = ConsoleWorldEntityUnderMouse()
local kitcoon = SpawnPrefab("kitcoon_deciduous")
if not kitcoon.components.hideandseekhider:GoHide(hidingspot, 0) then
kitcoon:Remove()
end
end
function d_hidekitcoons()
TheWorld.components.specialeventsetup:_SetupYearOfTheCatcoon()
end
function d_allkitcoons()
local kitcoons =
{
"kitcoon_forest",
"kitcoon_savanna",
"kitcoon_deciduous",
"kitcoon_marsh",
"kitcoon_grass",
"kitcoon_rocky",
"kitcoon_desert",
"kitcoon_moon",
"kitcoon_yot",
}
d_spawnlist(kitcoons, 3, function(inst) inst._first_nuzzle = false end)
end
function d_allcustomhidingspots()
local items = table.getkeys(TUNING.KITCOON_HIDING_OFFSET)
d_spawnlist(items, 6, function(hidingspot)
local kitcoon = SpawnPrefab("kitcoon_rocky")
if not kitcoon.components.hideandseekhider:GoHide(hidingspot, 0) then
kitcoon:Remove()
hidingspot.AnimState:SetMultColour(1, 0, 0)
end
end)
end