forked from pot0to/pot0to-SND-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCraftersScrips.lua
696 lines (649 loc) · 25.2 KB
/
CraftersScrips.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
--[[
********************************************************************************
* Orange Crafter Scrips (Solution Nine Patch 7.1) *
* Version 0.4.0 *
********************************************************************************
Created by: pot0to (https://ko-fi.com/pot0to)
State Machine Diagram: https://github.com/pot0to/pot0to-SND-Scripts/blob/main/FateFarmingStateMachine.drawio.png
Crafts orange scrip item matching whatever class you're on, turns it in, buys
stuff, repeat.
-> 0.4.0 Added purple scrips, fixed /li inn
Added HQ item count to out of materials check, continue turn in
items after dumping scrips
Fixed up some bugs
Fixed out of crystals check if recipe only needs one type of
crystal, added option to select what you want to buy with
scrips
Added check for ArtisanX crafting
Fixed some bugs with stop condition
Stops script when you're out of mats
Fixed some bugs related to /li inn
********************************************************************************
* Required Plugins *
********************************************************************************
1. SND
2. Artisan
3. Vnavmesh
4. Optional: Lifestream (for hiding in inn)
--------------------------------------------------------------------------------------------------------------------------------------------------------------
]]
--#region Settings
--[[
********************************************************************************
* Settings *
********************************************************************************
]]
CrafterClass = "Carpenter"
ScripColor = "Orange"
ArtisanIntermediatesListId = 42199 --Id of Artisan list for crafting all the intermediate materials (eg black star, claro walnut lumber, etc.)
ItemToBuy = "Crafter's Command Materia XII"
HomeCommand = "/li inn" --Command you use if you want to hide somewhere. Leave blank to stay in Solution Nine
HubCity = "Solution Nine" --Options:Limsa/Gridania/Ul'dah/Solution Nine. Where to turn in the scrips and access retainer bell
Potion = "Superior Spiritbond Potion <hq>" -- WARNING: This will overwrite any crafter's pots you have.
Retainers = true
GrandCompanyTurnIn = true
MinInventoryFreeSlots = 1
-- IMPORTANT: Your scrip exchange list may be different depending on whether
-- you've unlocked Skystell tools. Please make sure the menu item #s match what
-- you have in game.
ScripExchangeItems = {
{
itemName = "Condensed Solution",
categoryMenu = 1,
subcategoryMenu = 10,
listIndex = 0,
price = 125
},
{
itemName = "Crafter's Command Materia XII",
categoryMenu = 2,
subcategoryMenu = 2,
listIndex = 2,
price = 500
}
}
--#endregion Settings
--[[
********************************************************************************
* Code: Don't touch this unless you know what you're doing *
********************************************************************************
]]
OrangeCrafterScripId = 41784
OrangeScripRecipes =
{
{
className="Carpenter",
classId=8,
itemName="Rarefied Claro Walnut Fishing Rod",
itemId=44190,
recipeId=35787
},
{
className="Blacksmith",
classId=9,
itemName="Rarefied Ra'Kaznar Round Knife",
itemId=44196,
recipeId=35793
},
{
className="Armorer",
classId=10,
itemName="Rarefied Ra'Kaznar Ring",
itemId=44202,
recipeId=35799
},
{
className="Goldsmith",
classId=11,
itemName="Rarefied Black Star Earrings",
itemId=44208,
recipeId=35805
},
{
className="Leatherworker",
classId=12,
itemName="Rarefied Gargantuaskin Hat",
itemId=44214,
recipeId=35817
},
{
className="Weaver",
classId=13,
itemName="Rarefied Thunderyard Silk Culottes",
itemId=44220,
recipeId=35817
},
{
className="Alchemist",
classId=14,
itemName="Rarefied Claro Walnut Flat Brush",
itemId=44226,
recipeId=35823
},
{
className="Culinarian",
classId=15,
itemName="Rarefied Tacos de Carne Asada",
itemId=44232,
recipeId=35829
}
}
PurpleCrafterScripId = 33913
PurpleScripRecipes =
{
{
className="Carpenter",
classId=8,
itemName="Rarefied Claro Walnut Grinding Wheel",
itemId=44189,
recipeId=35786
},
{
className="Blacksmith",
classId=9,
itemName="Rarefied Ra'Kaznar War Scythe",
itemId=44195,
recipeId=35792
},
{
className="Armorer",
classId=10,
itemName="Rarefied Ra'Kaznar Greaves",
itemId=44201,
recipeId=35798
},
{
className="Goldsmith",
classId=11,
itemName="Rarefied Ra'Kaznar Orrery",
itemId=44207,
recipeId=35804
},
{
className="Leatherworker",
classId=12,
itemName="Rarefied Gargantuaskin Trouser",
itemId=44213,
recipeId=35816
},
{
className="Weaver",
classId=13,
itemName="Rarefied Thunderyards Silk Gloves",
itemId=44219,
recipeId=35816
},
{
className="Alchemist",
classId=14,
itemName="Rarefied Gemdraught of Vitality",
itemId=44225,
recipeId=35822
},
{
className="Culinarian",
classId=15,
itemName="Rarefied Stuffed Peppers",
itemId=44231,
recipeId=35828
}
}
HubCities =
{
{
zoneName="Limsa",
zoneId = 129,
aethernet = {
aethernetZoneId = 129,
aethernetName = "Hawkers' Alley",
x=-213.61108, y=16.739136, z=51.80432
},
retainerBell = { x=-123.88806, y=17.990356, z=21.469421, requiresAethernet=false },
scripExchange = { x=-258.52585, y=16.2, z=40.65883, requiresAethernet=true }
},
{
zoneName="Gridania",
zoneId = 132,
aethernet = {
aethernetZoneId = 133,
aethernetName = "Leatherworkers' Guild & Shaded Bower",
x=131.9447, y=4.714966, z=-29.800903
},
retainerBell = { x=168.72, y=15.5, z=-100.06, requiresAethernet=true },
scripExchange = { x=142.15, y=13.74, z=-105.39, requiresAethernet=true },
},
{
zoneName="Ul'dah",
zoneId = 130,
aethernet = {
aethernetZoneId = 131,
aethernetName = "Sapphire Avenue Exchange",
x=101, y=9, z=-112
},
retainerBell = { x=171, y=15, z=-102, requiresAethernet=true },
scripExchange = { x=142.68, y=13.75, z=-104.59, requiresAethernet=true },
},
{
zoneName="Solution Nine",
zoneId = 1186,
aethernet = {
aethernetZoneId = 1186,
aethernetName = "Nexus Arcade",
x=-161, y=-1, z=21
},
retainerBell = { x=-152.465, y=0.660, z=-13.557, requiresAethernet=true },
scripExchange = { x=-158.019, y=0.922, z=-37.884, requiresAethernet=true }
}
}
ClassList =
{
crp = { classId=8, className="Carpenter" },
bsm = { classId=9, className="Blacksmith" },
arm = { classId=10, className="Armorer" },
gsm = { classId=11, className="Goldsmith" },
ltw = { classId=12, className="Leatherworker" },
wvr = { classId=13, className="Weaver" },
alc = { classId=14, className="Alchemist" },
cul = { classId=15, className="Culinarian"}
}
CharacterCondition =
{
craftingMode = 5,
casting=27,
occupiedInQuestEvent=32,
occupiedMateriaExtractionAndRepair=39,
executingCraftingSkill = 40,
craftingModeIdle = 41,
betweenAreas=45,
occupiedSummoningBell=50,
beingMoved=70,
}
function TeleportTo(aetheryteName)
yield("/tp "..aetheryteName)
yield("/wait 1") -- wait for casting to begin
while GetCharacterCondition(CharacterCondition.casting) do
LogInfo("[FATE] Casting teleport...")
yield("/wait 1")
end
yield("/wait 1") -- wait for that microsecond in between the cast finishing and the transition beginning
while GetCharacterCondition(CharacterCondition.betweenAreas) do
LogInfo("[FATE] Teleporting...")
yield("/wait 1")
end
yield("/wait 1")
end
function OutOfCrystals()
local crystalsRequired1 = tonumber(GetNodeText("RecipeNote", 28, 4))
local crystalsInInventory1 = tonumber(GetNodeText("RecipeNote", 28, 3))
if crystalsRequired1 ~= nil and crystalsInInventory1 ~= nil and crystalsRequired1 > crystalsInInventory1 then
return true
end
local crystalsRequired2 = tonumber(GetNodeText("RecipeNote", 29, 4))
local crystalsInInventory2 = tonumber(GetNodeText("RecipeNote", 29, 3))
if crystalsRequired2 ~= nil and crystalsInInventory2 ~= nil and crystalsRequired2> crystalsInInventory2 then
return true
end
return false
end
function OutOfMaterials()
for i=0,5 do
local materialCountNQ = GetNodeText("RecipeNote", 18 + i, 8)
local materialCountHQ = GetNodeText("RecipeNote", 18 + i, 5)
local materialRequirement = GetNodeText("RecipeNote", 18 + i, 15)
if materialCountNQ ~= "" and materialCountHQ ~= "" and materialRequirement ~= "" then
if tonumber(materialCountNQ) + tonumber(materialCountHQ) < tonumber(materialRequirement) then
return true
end
end
end
if OutOfCrystals() then
yield("/echo Out of crystals. Stopping script.")
StopFlag = true
return true
end
return false
end
function Crafting()
if (HasPlugin("Lifestream") and LifestreamIsBusy()) or GetCharacterCondition(CharacterCondition.occupiedInQuestEvent) then
yield("/wait 1")
return
elseif not AtInn and HomeCommand ~= "" then
yield(HomeCommand)
while LifestreamIsBusy() do
yield("/wait 1")
end
AtInn = true
return
end
local slots = GetInventoryFreeSlotCount()
if (ArtisanIsListRunning() and not ArtisanIsListPaused()) or IsAddonVisible("Synthesis") then
yield("/wait 1")
elseif slots <= MinInventoryFreeSlots then
LogInfo("[OrangeCrafters] Out of inventory space")
if IsAddonVisible("RecipeNote") then
yield("/callback RecipeNote true -1")
elseif not GetCharacterCondition(CharacterCondition.craftingMode) then
State = CharacterState.turnIn
LogInfo("State Change: TurnIn")
end
elseif IsAddonVisible("RecipeNote") and OutOfMaterials() then
LogInfo("[OrangeCrafters] Out of materials")
if not StopFlag then
if slots > MinInventoryFreeSlots and (ArtisanTimeoutStartTime == 0) then
LogInfo("[OrangeCrafters] Attempting to craft intermediate materials")
yield("/artisan lists "..ArtisanIntermediatesListId.." start")
ArtisanTimeoutStartTime = os.clock()
elseif GetItemCount(ItemId) > 0 then
LogInfo("[OrangeCrafters] Turning In")
yield("/callback RecipeNote true -1")
State = CharacterState.turnIn
LogInfo("[OrangeCrafters] State Change: TurnIn")
elseif os.clock() - ArtisanTimeoutStartTime > 5 then
LogInfo("[OrangeCrafters] Artisan not starting, StopFlag = true")
-- if artisan has not entered crafting mode within 15s of being called,
-- then you're probably out of mats so just stop the script
yield("/echo Artisan took too long to start. Are you out of intermediate mat materials?")
StopFlag = true
end
end
elseif not IsAddonVisible("Synthesis") then -- GetCharacterCondition(CharacterCondition.craftingMode) then
LogInfo("[OrangeCrafters] Attempting to craft "..(slots - MinInventoryFreeSlots).." of recipe #"..RecipeId)
ArtisanTimeoutStartTime = 0
ArtisanCraftItem(RecipeId, slots - MinInventoryFreeSlots)
yield("/wait 5")
end
end
function GoToHubCity()
if not IsPlayerAvailable() then
yield("/wait 1")
elseif not IsInZone(SelectedHubCity.zoneId) then
TeleportTo(SelectedHubCity.aetheryte)
else
State = CharacterState.ready
LogInfo("State Change: Ready")
end
end
function TurnIn()
AtInn = false
if GetItemCount(ItemId) == 0 or GetItemCount(CrafterScripId) >= 3800 then
if IsAddonVisible("CollectablesShop") then
yield("/callback CollectablesShop true -1")
else
State = CharacterState.ready
LogInfo("State Change: Ready")
end
elseif not IsInZone(SelectedHubCity.zoneId) and
(not SelectedHubCity.scripExchange.requiresAethernet or (SelectedHubCity.scripExchange.requiresAethernet and not IsInZone(SelectedHubCity.aethernet.aethernetZoneId)))
then
State = CharacterState.goToHubCity
LogInfo("State Change: GoToHubCity")
elseif not LogInfo("Logging 1") and SelectedHubCity.scripExchange.requiresAethernet and not LogInfo("Logging 2") and (not IsInZone(SelectedHubCity.aethernet.aethernetZoneId) or
GetDistanceToPoint(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) > DistanceBetween(SelectedHubCity.aethernet.x, SelectedHubCity.aethernet.y, SelectedHubCity.aethernet.z, SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) + 10) then
if not LifestreamIsBusy() then
LogInfo("[OrangeCrafters] /li "..SelectedHubCity.aethernet.aethernetName)
yield("/li "..SelectedHubCity.aethernet.aethernetName)
end
yield("/wait 3")
elseif IsAddonVisible("TelepotTown") then
LogInfo("TelepotTown open")
yield("/callback TelepotTown false -1")
elseif GetDistanceToPoint(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) > 1 then
if not (PathfindInProgress() or PathIsRunning()) then
LogInfo("Path not running")
PathfindAndMoveTo(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z)
end
else
if PathfindInProgress() or PathIsRunning() then
yield("/vnav stop")
end
if not IsAddonVisible("CollectablesShop") then
yield("/target Collectable Appraiser")
yield("/wait 0.5")
yield("/interact")
yield("/wait 1")
else
yield("/callback CollectablesShop true 15 0")
yield("/wait 1")
end
end
end
function ScripExchange()
if GetItemCount(CrafterScripId) < 3800 then
if IsAddonVisible("InclusionShop") then
yield("/callback InclusionShop true -1")
elseif GetItemCount(ItemId) > 0 then
State = CharacterState.turnIn
LogInfo("[OrangeCrafters] State Change: TurnIn")
else
State = CharacterState.ready
LogInfo("[OrangeCrafters] State Change: Ready")
end
elseif not IsInZone(SelectedHubCity.zoneId) and
(not SelectedHubCity.scripExchange.requiresAethernet or (SelectedHubCity.scripExchange.requiresAethernet and not IsInZone(SelectedHubCity.aethernet.aethernetZoneId)))
then
State = CharacterState.goToHubCity
LogInfo("State Change: GoToHubCity")
elseif SelectedHubCity.scripExchange.requiresAethernet and (not IsInZone(SelectedHubCity.aethernet.aethernetZoneId) or
GetDistanceToPoint(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) > DistanceBetween(SelectedHubCity.aethernet.x, SelectedHubCity.aethernet.y, SelectedHubCity.aethernet.z, SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) + 10) then
if not LifestreamIsBusy() then
yield("/li "..SelectedHubCity.aethernet.aethernetName)
end
yield("/wait 3")
elseif IsAddonVisible("TelepotTown") then
yield("/callback TelepotTown true -1")
elseif GetDistanceToPoint(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) > 1 then
if not (PathfindInProgress() or PathIsRunning()) then
LogInfo("[OrangeCrafters] Path not running")
PathfindAndMoveTo(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z)
end
elseif IsAddonVisible("ShopExchangeItemDialog") then
yield("/callback ShopExchangeItemDialog true 0")
yield("/wait 1")
elseif IsAddonVisible("SelectIconString") then
yield("/callback SelectIconString true 0")
elseif IsAddonVisible("InclusionShop") then
yield("/callback InclusionShop true 12 "..SelectedItemToBuy.categoryMenu)
yield("/wait 1")
yield("/callback InclusionShop true 13 "..SelectedItemToBuy.subcategoryMenu)
yield("/wait 1")
yield("/callback InclusionShop true 14 "..SelectedItemToBuy.listIndex.." "..GetItemCount(CrafterScripId)//SelectedItemToBuy.price)
else
yield("/wait 1")
yield("/target Scrip Exchange")
yield("/wait 0.5")
yield("/interact")
end
end
function ProcessRetainers()
CurrentFate = nil
LogInfo("[OrangeCrafters] Handling retainers...")
if not LogInfo("[OrangeCrafters] check retainers ready") and not ARRetainersWaitingToBeProcessed() or GetInventoryFreeSlotCount() <= 1 then
if IsAddonVisible("RetainerList") then
yield("/callback RetainerList true -1")
elseif not GetCharacterCondition(CharacterCondition.occupiedSummoningBell) then
State = CharacterState.ready
LogInfo("[FATE] State Change: Ready")
end
else
yield("/target Summoning Bell")
yield("/wait 1")
if GetTargetName() == "Summoning Bell" then
if GetDistanceToTarget() > 5 then
if not PathIsRunning() and not PathfindInProgress() then
PathfindAndMoveTo(GetTargetRawXPos(), GetTargetRawYPos(), GetTargetRawZPos())
end
else
if PathIsRunning() or PathfindInProgress() then
yield("/vnav stop")
end
if not GetCharacterCondition(CharacterCondition.occupiedSummoningBell) then
yield("/interact")
elseif IsAddonVisible("RetainerList") then
yield("/ays e")
if Echo == "All" then
yield("/echo [OrangeCrafters] Processing retainers")
end
yield("/wait 1")
end
end
elseif not LogInfo("[OrangeCrafters] is in hub city zone?") and not IsInZone(SelectedHubCity.zoneId) and
(not SelectedHubCity.scripExchange.requiresAethernet or (SelectedHubCity.scripExchange.requiresAethernet and not IsInZone(SelectedHubCity.aethernet.aethernetZoneId)))
then
TeleportTo(SelectedHubCity.aetheryte)
elseif not LogInfo("[OrangeCrafters] use aethernet?") and
SelectedHubCity.retainerBell.requiresAethernet and not LogInfo("abc") and (not IsInZone(SelectedHubCity.aethernet.aethernetZoneId) or
(GetDistanceToPoint(SelectedHubCity.retainerBell.x, SelectedHubCity.retainerBell.y, SelectedHubCity.retainerBell.z) > (DistanceBetween(SelectedHubCity.aethernet.x, SelectedHubCity.aethernet.y, SelectedHubCity.aethernet.z, SelectedHubCity.retainerBell.x, SelectedHubCity.retainerBell.y, SelectedHubCity.retainerBell.z) + 10)))
then
if not LifestreamIsBusy() then
yield("/li "..SelectedHubCity.aethernet.aethernetName)
end
yield("/wait 3")
elseif not LogInfo("[OrangeCrafters] close telepot town") and IsAddonVisible("TelepotTown") then
LogInfo("TelepotTown open")
yield("/callback TelepotTown false -1")
elseif not LogInfo("[OrangeCrafters] move to summoning bell") and GetDistanceToPoint(SelectedHubCity.retainerBell.x, SelectedHubCity.retainerBell.y, SelectedHubCity.retainerBell.z) > 1 then
if not (PathfindInProgress() or PathIsRunning()) then
LogInfo("Path not running")
PathfindAndMoveTo(SelectedHubCity.retainerBell.x, SelectedHubCity.retainerBell.y, SelectedHubCity.retainerBell.z)
end
elseif PathfindInProgress() or PathIsRunning() then
return
elseif not HasTarget() or GetTargetName() ~= "Summoning Bell" then
yield("/target Summoning Bell")
return
elseif not GetCharacterCondition(CharacterCondition.occupiedSummoningBell) then
yield("/interact")
elseif IsAddonVisible("RetainerList") then
yield("/ays e")
if Echo == "All" then
yield("/echo [FATE] Processing retainers")
end
yield("/wait 1")
end
end
end
function ExecuteGrandCompanyTurnIn()
if GetInventoryFreeSlotCount() <= MinInventoryFreeSlots then
local playerGC = GetPlayerGC()
local gcZoneIds = {
129, --Limsa Lominsa
132, --New Gridania
130 --"Ul'dah - Steps of Nald"
}
if not IsInZone(gcZoneIds[playerGC]) then
yield("/li gc")
yield("/wait 1")
elseif DeliverooIsTurnInRunning() then
return
else
yield("/deliveroo enable")
end
else
State = CharacterState.ready
LogInfo("State Change: Ready")
end
end
function PotionCheck()
--pot usage
if not HasStatusId(49) and Potion ~= "" then
yield("/item " .. Potion)
end
end
function Ready()
PotionCheck()
if not IsPlayerAvailable() then
-- do nothing
elseif Retainers and ARRetainersWaitingToBeProcessed() and GetInventoryFreeSlotCount() > 1
then
State = CharacterState.retainers
LogInfo("[OrangeCrafters] State Change: ProcessingRetainers")
elseif GetItemCount(CrafterScripId) >= 3800 then
State = CharacterState.scripExchange
LogInfo("[OrangeCrafters] State Change: ScripExchange")
elseif GetInventoryFreeSlotCount() <= MinInventoryFreeSlots and GetItemCount(ItemId) > 0 then
State = CharacterState.turnIn
LogInfo("State Change: TurnIn")
elseif not LogInfo("[OrangeCrafters] Ready -> GC TurnIn") and GrandCompanyTurnIn and
GetInventoryFreeSlotCount() <= MinInventoryFreeSlots
then
State = CharacterState.gcTurnIn
LogInfo("[OrangeCrafters] State Change: GCTurnIn")
else
State = CharacterState.crafting
LogInfo("[OrangeCrafters] State Change: Crafting")
end
end
CharacterState =
{
ready = Ready,
crafting = Crafting,
goToHubCity = GoToHubCity,
turnIn = TurnIn,
scripExchange = ScripExchange,
retainers = ProcessRetainers,
gcTurnIn = ExecuteGrandCompanyTurnIn
}
State = CharacterState.ready
local classId = 0
for _, class in pairs(ClassList) do
if CrafterClass == class.className then
classId = class.classId
end
end
if classId == 0 then
yield("/echo Could not find crafter class: "..CrafterClass)
yield("/snd stop")
end
if ScripColor == "Orange" then
CrafterScripId = OrangeCrafterScripId
ScripRecipes = OrangeScripRecipes
elseif ScripColor == "Purple" then
CrafterScripId = PurpleScripRecipes
ScripRecipes = PurpleScripRecipes
else
yield("/echo Cannot recognize crafter scrip color: "..ScripColor)
yield("/snd stop")
end
ItemId = 0
RecipeId = 0
for _, data in ipairs(ScripRecipes) do
if data.classId == classId then
ItemId = data.itemId
RecipeId = data.recipeId
end
end
for _, item in ipairs(ScripExchangeItems) do
if item.itemName == ItemToBuy then
SelectedItemToBuy = item
end
end
if SelectedItemToBuy == nil then
yield("/echo Could not find "..ItemToBuy.." on the list of scrip exchange items.")
StopFlag = true
end
for _, city in ipairs(HubCities) do
if city.zoneName == HubCity then
SelectedHubCity = city
SelectedHubCity.aetheryte = GetAetheryteName(GetAetherytesInZone(city.zoneId)[0])
end
end
if SelectedHubCity == nil then
yield("/echo Could not find hub city: "..HubCity)
yield("/vnav stop")
end
AtInn = false
StopFlag = false
ArtisanTimeoutStartTime = 0
LogInfo("[OrangeCrafters] Start")
while not StopFlag do
if not (
IsPlayerCasting() or
GetCharacterCondition(CharacterCondition.betweenAreas) or
GetCharacterCondition(CharacterCondition.beingMoved) or
GetCharacterCondition(CharacterCondition.occupiedMateriaExtractionAndRepair) or
LifestreamIsBusy())
then
State()
end
yield("/wait 0.1")
end