Back to Home

ESO Lua File v101044

ingame/crafting/scribing_shared.lua

[◄ back to folders ]
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
ZO_SCRIBING_MODE_NONE = 0
ZO_SCRIBING_MODE_SCRIBE = 1
ZO_SCRIBING_MODE_RECENT = 2
ZO_RECENT_SCRIBE_SAVED_VAR_INDEX =
{
    CRAFTED_ABILITY = 1,
    PRIMARY_SCRIPT = 2,
    SECONDARY_SCRIPT = 3,
    TERTIARY_SCRIPT = 4,
}
local INTERACTION =
{
    type = "ScribingStation",
    interactTypes = { INTERACTION_CRAFT },
}
local SHOW_POSITIVE_DROP_CALLOUT = true
local SHOW_NEGATIVE_DROP_CALLOUT = false
ZO_SharedScribingSlotAnimation = ZO_CraftingCreateSlotAnimation:Subclass()
function ZO_SharedScribingSlotAnimation:GetLockInSound(slot)
    return SOUNDS.SCRIBING_SCRIBE_SLOT_ANIMATED
end
ZO_Scribing_Shared = ZO_DeferredInitializingObject:Subclass()
function ZO_Scribing_Shared:Initialize(control, interactSceneName)
    self.control = control
    self.interactScene = self:CreateInteractScene(interactSceneName)
    ZO_DeferredInitializingObject.Initialize(self, self.interactScene)
end
function ZO_Scribing_Shared:CreateInteractScene(name)
    return ZO_InteractScene:New(name, SCENE_MANAGER, INTERACTION)
end
function ZO_Scribing_Shared:OnDeferredInitialize()
end
function ZO_Scribing_Shared:InitializeSlots()
    self.slotsContainer = self.control:GetNamedChild("SlotsContainer")
    self.slotsInkCostLabel = nil
    self.scribingSlots = {}
    self.slotAnimation = ZO_SharedScribingSlotAnimation:New(self.interactScene:GetName(), function() return self:IsShowing() end)
end
function ZO_Scribing_Shared:SetCraftedAbilitySlot(slotObject)
    self.craftedAbilitySlot = slotObject
    self.slotAnimation:AddSlot(slotObject)
end
function ZO_Scribing_Shared:AddScriptSlot(slotType, slotObject)
    self.scribingSlots[slotType] = slotObject
    self.slotAnimation:AddSlot(slotObject)
end
function ZO_Scribing_Shared:InitializeFilters()
    self.scriptFilters =
    {
        isUsable = true,
    }
end
function ZO_Scribing_Shared:InitializeEvents()
    CALLBACK_MANAGER:RegisterCallback("CraftingAnimationsStopped", function()
        self:OnScribeComplete()
    end)
end
function ZO_Scribing_Shared:InitializeKeybindStripDescriptors()
    -- To be overridden
end
function ZO_Scribing_Shared:OnShow()
    TriggerTutorial(TUTORIAL_TRIGGER_SCRIBING_OPENED)
end
function ZO_Scribing_Shared:OnHiding()
    -- To be overridden
end
function ZO_Scribing_Shared:OnHidden()
end
function ZO_Scribing_Shared:IsShowing()
    return self.interactScene:IsShowing()
end
function ZO_Scribing_Shared:ShouldCraftButtonBeEnabled()
        return false
    end
    local primaryScriptId, secondaryScriptId, tertiaryScriptId = self:GetSlottedScriptIds()
    if primaryScriptId == 0 or secondaryScriptId == 0 or tertiaryScriptId == 0 then
        return false, GetString("SI_TRADESKILLRESULT", CRAFTING_RESULT_EMPTY_SCRIPT_SLOT)
    end
    if not (self:IsScriptIdUnlocked(primaryScriptId) and self:IsScriptIdUnlocked(secondaryScriptId) and self:IsScriptIdUnlocked(tertiaryScriptId)) then
        return false, GetString("SI_TRADESKILLRESULT", CRAFTING_RESULT_UNOWNED_SCRIPT)
    end
    
    local craftedAbilityData = self:GetSlottedCraftedAbilityData()
    if not craftedAbilityData:IsScribableScriptIdCombination(primaryScriptId, secondaryScriptId, tertiaryScriptId) then
        return false, GetString("SI_TRADESKILLRESULT", CRAFTING_RESULT_INVALID_SCRIBING_COMBINATION)
    end
    if craftedAbilityData:AreScriptIdsActive(primaryScriptId, secondaryScriptId, tertiaryScriptId) then
        return false, GetString("SI_TRADESKILLRESULT", CRAFTING_RESULT_SKILL_UNCHANGED)
    end
    return true
end
function ZO_Scribing_Shared:OnScribeComplete()
    local craftedAbilityData = self:GetSlottedCraftedAbilityData()
    if craftedAbilityData then
        local recentCraftedAbilities = self:GetRecentCraftedAbilities()
        local primaryScriptId, secondaryScriptId, tertiaryScriptId = self:GetSlottedScriptIds()
        for i = 1, #recentCraftedAbilities do
            if SCRIBING_MANAGER:IsRecentCraftedAbilityIndexEqual(i, craftedAbilityData:GetId(), primaryScriptId, secondaryScriptId, tertiaryScriptId) then
                table.remove(recentCraftedAbilities, i)
                break
            end
        end
        table.insert(recentCraftedAbilities, { craftedAbilityData:GetId(), primaryScriptId, secondaryScriptId, tertiaryScriptId })
    end
    if self:IsShowing() then
        self:ShowCraftedAbilities()
        local canSeeAbilityScribedTutorial = CanTutorialBeSeen(TUTORIAL_TRIGGER_SCRIBING_ABILITY_SCRIBED)
        if canSeeAbilityScribedTutorial then
            TriggerTutorial(TUTORIAL_TRIGGER_SCRIBING_ABILITY_SCRIBED)
        end
        if self.initialScribe then
            if canSeeAbilityScribedTutorial then
                -- we need to delay the open skill dialog until after the tutorial is shown
                zo_callLater(function() ZO_Dialogs_ShowPlatformDialog("SCRIBING_OPEN_SKILLS_CONFIRM", { skillsData = craftedAbilityData:GetSkillData() }) end, 500)
            else
                ZO_Dialogs_ShowPlatformDialog("SCRIBING_OPEN_SKILLS_CONFIRM", { skillsData = craftedAbilityData:GetSkillData() })
            end
        end
        self.initialScribe = nil
    end
end
function ZO_Scribing_Shared:ShowCraftedAbilities(resetToTop)
    self:RefreshCraftedAbilityList(resetToTop)
end
function ZO_Scribing_Shared:RefreshCraftedAbilityList(resetToTop)
    self:RefreshSlots()
end
function ZO_Scribing_Shared:ShowScripts()
    local RESET_TO_TOP = true
    self:RefreshScriptsList(RESET_TO_TOP)
end
function ZO_Scribing_Shared:RefreshScriptsList(resetToTop)
    self:RefreshSlots()
end
function ZO_Scribing_Shared:GetRecentCraftedAbilities()
    return SCRIBING_MANAGER:GetRecentCraftedAbilities()
end
function ZO_Scribing_Shared:UpdateInkDisplay()
    -- To be overridden
end
function ZO_Scribing_Shared:UpdateResultTooltip()
    -- To be overridden
end
function ZO_Scribing_Shared:SlotCraftedAbilityById(craftedAbilityId)
    local craftedAbilityData = SCRIBING_DATA_MANAGER:GetCraftedAbilityData(craftedAbilityId)
    if craftedAbilityData then
        self.craftedAbilitySlot:SetCraftedAbilityId(craftedAbilityId)
        craftedAbilityData:SetScriptIdSelectionOverride(0, 0, 0)
        self:ShowScripts()
        TriggerTutorial(TUTORIAL_TRIGGER_SCRIBING_GRIMOIRE_SELECTED)
    else
        self.craftedAbilitySlot:SetCraftedAbilityId(0)
        self:ShowCraftedAbilities()
    end
end
function ZO_Scribing_Shared:SlotScriptById(scriptId)
    local scriptData = self:GetScriptDataById(scriptId)
    if scriptData then
        if self:IsScriptDataSlotted(scriptData) then
            -- Remove slotted script
            local scribingSlot = scriptData:GetScribingSlot()
            self:ClearScriptIdBySlot(scribingSlot)
        else
            -- Add script to slot
            self:SlotScriptIdByScriptData(scriptData)
            TriggerTutorial(TUTORIAL_TRIGGER_SCRIBING_SCRIPT_SELECTED)
        end
    end
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_Scribing_Shared:ClearCurrentScribingSelection()
    self.craftedAbilitySlot:ClearCraftedAbilityId()
end
function ZO_Scribing_Shared:ClearSelectedScripts()
    for scribingSlot = SCRIBING_SLOT_ITERATION_BEGIN, SCRIBING_SLOT_ITERATION_END do
        self:ClearScriptIdBySlot(scribingSlot)
    end
    self:RefreshSlots()
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_Scribing_Shared:GetSlottedCraftedAbilityId()
    return self.craftedAbilitySlot:GetCraftedAbilityId()
end
function ZO_Scribing_Shared:GetSlottedCraftedAbilityData()
    return SCRIBING_DATA_MANAGER:GetCraftedAbilityData(self:GetSlottedCraftedAbilityId())
end
function ZO_Scribing_Shared:HasCraftedAbilitySlotted()
    return self:GetSlottedCraftedAbilityId() ~= 0
end
function ZO_Scribing_Shared:SlotScriptId(scriptId)
    local scriptData = self:GetScriptDataById(scriptId)
    if scriptData then
        self:SlotScriptIdByScriptData(scriptData)
    end
end
function ZO_Scribing_Shared:GetScriptDataDisabledColor()
    return ZO_DISABLED_TEXT
end
function ZO_Scribing_Shared:SlotScriptIdByScriptData(scriptData)
    local craftedAbilityData = self:GetSlottedCraftedAbilityData()
    if craftedAbilityData then
        local isScriptCompatible = self:IsScriptDataCompatible(craftedAbilityData:GetId(), scriptData)
        self.scribingSlots[scriptData:GetScribingSlot()]:SetScriptId(scriptData:GetId(), isScriptCompatible, self:GetScriptDataDisabledColor())
    end
end
function ZO_Scribing_Shared:GetScriptIdBySlot(slotType)
    return self.scribingSlots[slotType]:GetScriptId()
end
function ZO_Scribing_Shared:GetSlottedScriptIds()
    return self:GetScriptIdBySlot(SCRIBING_SLOT_PRIMARY), self:GetScriptIdBySlot(SCRIBING_SLOT_SECONDARY), self:GetScriptIdBySlot(SCRIBING_SLOT_TERTIARY)
end
function ZO_Scribing_Shared:GetScriptDataById(scriptId)
    return SCRIBING_DATA_MANAGER:GetCraftedAbilityScriptData(scriptId)
end
function ZO_Scribing_Shared:ClearScriptIdBySlot(slotType)
    self.scribingSlots[slotType]:ClearScriptId()
end
function ZO_Scribing_Shared:IsScriptIdSlotted(scriptId)
    local scriptData = SCRIBING_DATA_MANAGER:GetCraftedAbilityScriptData(scriptId)
    return self:IsScriptDataSlotted(scriptData)
end
function ZO_Scribing_Shared:IsScriptDataSlotted(scriptData)
    return self.scribingSlots[scriptData:GetScribingSlot()]:GetScriptId() == scriptData:GetId()
end
function ZO_Scribing_Shared:IsScriptIdCompatibleWithFilters(craftedAbilityId, scriptId)
    if self.scriptFilters then
        local scriptData = self:GetScriptDataById(scriptId)
        local primaryScriptId, secondaryScriptId, tertiaryScriptId = self:GetSlottedScriptIds()
        if not self.scriptFilters.isUsable or (scriptData:IsCompatibleWithSelections(craftedAbilityId, primaryScriptId, secondaryScriptId, tertiaryScriptId) and scriptData:IsUnlocked()) then
            return true
        end
    else
        return true
    end
    return false
end
function ZO_Scribing_Shared:IsAnyScriptSlotted()
    for scribingSlot = SCRIBING_SLOT_ITERATION_BEGIN, SCRIBING_SLOT_ITERATION_END do
        if self:GetScriptIdBySlot(scribingSlot) ~= 0 then
            return true
        end
    end
    return false
end
function ZO_Scribing_Shared:IsScriptIdUnlocked(scriptId)
    local scriptData = SCRIBING_DATA_MANAGER:GetCraftedAbilityScriptData(scriptId)
    return scriptData and scriptData:IsUnlocked()
end
function ZO_Scribing_Shared:ScribeCurrentSelection()
    local primaryScriptId, secondaryScriptId, tertiaryScriptId = self:GetSlottedScriptIds()
    self.initialScribe = self:GetSlottedCraftedAbilityData():GetAbilityId() == 0
    RequestScribe(self:GetSlottedCraftedAbilityId(), primaryScriptId, secondaryScriptId, tertiaryScriptId)
end
function ZO_Scribing_Shared:UpdateCraftingCost()
    if self.slotsInkCostLabel then
        local hasSlottedAnyScripts = self:IsAnyScriptSlotted()
        self.slotsInkCostLabel:SetHidden(not hasSlottedAnyScripts)
        if hasSlottedAnyScripts then
            local inkIcon = ZO_Scribing_Manager.GetScribingInkIcon()
            local primaryScript, secondaryScript, tertiaryScript = self:GetSlottedScriptIds()
            local inkAmount = GetCostToScribeScripts(self:GetSlottedCraftedAbilityId(), primaryScript, secondaryScript, tertiaryScript)
            self.slotsInkCostLabel:SetText(zo_iconTextFormatNoSpaceAlignedRight(inkIcon, "100%", "100%", inkAmount))
        end
    end
end
function ZO_Scribing_Shared:RefreshSlots()
end
function ZO_Scribing_Shared:SelectScriptId(scriptId)
    self:SlotScriptById(scriptId)
end
function ZO_Scribing_Shared:SelectRecentCraftedAbilityData(recentCraftedAbilityData)
    local craftedAbilityId = recentCraftedAbilityData[ZO_RECENT_SCRIBE_SAVED_VAR_INDEX.CRAFTED_ABILITY]
    local primaryScriptId = recentCraftedAbilityData[ZO_RECENT_SCRIBE_SAVED_VAR_INDEX.PRIMARY_SCRIPT]
    local secondaryScriptId = recentCraftedAbilityData[ZO_RECENT_SCRIBE_SAVED_VAR_INDEX.SECONDARY_SCRIPT]
    local tertiaryScriptId = recentCraftedAbilityData[ZO_RECENT_SCRIBE_SAVED_VAR_INDEX.TERTIARY_SCRIPT]
    self:SetupRecentCraftedAbilityToCraft(craftedAbilityId, primaryScriptId, secondaryScriptId, tertiaryScriptId)
end
function ZO_Scribing_Shared:SetupRecentCraftedAbilityToCraft(craftedAbilityId, primaryScriptId, secondaryScriptId, tertiaryScriptId)
    self:SelectCraftedAbilityId(craftedAbilityId)
    self:SelectScriptId(primaryScriptId)
    self:SelectScriptId(secondaryScriptId)
    self:SelectScriptId(tertiaryScriptId)
end
function ZO_Scribing_Shared:ShowSlotDropCalloutsForCraftedAbility(craftedAbilityId)
    for slotType, slot in pairs(self.scribingSlots) do
        slot:ShowDropCallout(SHOW_NEGATIVE_DROP_CALLOUT)
    end 
    self.craftedAbilitySlot:ShowDropCallout(SHOW_POSITIVE_DROP_CALLOUT)
end
function ZO_Scribing_Shared:ShowSlotDropCalloutsForCraftedAbilityScript(scriptId)
    local scriptData = self:GetScriptDataById(scriptId)
    local selectedSlotType = SCRIBING_SLOT_NONE
    if scriptData then
        selectedSlotType = scriptData:GetScribingSlot()
    end
    for slotType, slot in pairs(self.scribingSlots) do
        slot:ShowDropCallout(selectedSlotType == slotType)
    end
    self.craftedAbilitySlot:ShowDropCallout(SHOW_NEGATIVE_DROP_CALLOUT)
end
function ZO_Scribing_Shared:HideAllSlotDropCallouts()
    for slotType, slot in pairs(self.scribingSlots) do
        slot:HideDropCallout()
    end 
    self.craftedAbilitySlot:HideDropCallout()
end
ZO_SharedCraftedAbilitySlot = ZO_InitializingCallbackObject:Subclass()
function ZO_SharedCraftedAbilitySlot:Initialize(owner, control, emptyTexture, dropCalloutTexturePositive, dropCalloutTextureNegative, placeSound, removeSound, emptySlotIcon)
    ZO_InitializingCallbackObject.Initialize(self)
    self.owner = owner
    self.control = control
    control.slot = self
    self.emptyTexture = emptyTexture
    if emptySlotIcon then
        self.emptyTexture = emptySlotIcon
        self.useEmptySlotIcon = true
        self.emptySlotOverrideIcon = self.control:GetNamedChild("EmptySlotIcon")
        internalassert(self.emptySlotOverrideIcon ~= nil)
    end
    self.nameLabel = control:GetNamedChild("Name")
    self.dropCalloutTexturePositive = dropCalloutTexturePositive
    self.dropCalloutTextureNegative = dropCalloutTextureNegative
    self.placeSound = placeSound
    self.removeSound = removeSound
    -- required
    self.slotIcon = self.control:GetNamedChild("Icon")
    self.dropCallout = self.control:GetNamedChild("DropCallout")
    -- optional
    self.iconBg = self.control:GetNamedChild("IconBg")
end
function ZO_SharedCraftedAbilitySlot:SetCraftedAbilityId(craftedAbilityId)
    if self.craftedAbilityId == craftedAbilityId then
        return
    end
    local hadCraftedAbility = self.craftedAbilityId and self.craftedAbilityId > 0
    self.craftedAbilityId = craftedAbilityId
    local craftedAbilityData = SCRIBING_DATA_MANAGER:GetCraftedAbilityData(craftedAbilityId)
    local isEmpty = not craftedAbilityData
    if self.useEmptySlotIcon then
        if isEmpty and self.emptyTexture == "" then
            -- Empty string represents no icon, in this case we should just hide both inventory slot icon and our empty slot override
            self.emptySlotOverrideIcon:SetHidden(true)
            self.slotIcon:SetHidden(true)
        else
            self.emptySlotOverrideIcon:SetTexture(self.emptyTexture)
            self.emptySlotOverrideIcon:SetHidden(not isEmpty)
            if craftedAbilityData then
                self.slotIcon:SetTexture(craftedAbilityData:GetIcon())
            end
            self.slotIcon:SetHidden(isEmpty)
        end
    else
        self.slotIcon:SetHidden(false)
        if isEmpty then
            self.slotIcon:SetTexture(self.emptyTexture)
        else
            self.slotIcon:SetTexture(craftedAbilityData:GetIcon())
        end
    end
    if self.nameLabel then
        if not isEmpty then
            self.nameLabel:SetHidden(false)
            self.nameLabel:SetText(craftedAbilityData:GetFormattedName())
        else
            self.nameLabel:SetHidden(true)
        end
    end
    if self.iconBg then
        self.iconBg:SetHidden(self.craftedAbilityId == nil or self.craftedAbilityId == 0)
    end
    if self.craftedAbilityId ~= 0 then
        PlaySound(self.placeSound)
    elseif hadCraftedAbility then
        PlaySound(self.removeSound)
    end
end
function ZO_SharedCraftedAbilitySlot:ClearCraftedAbilityId()
end
function ZO_SharedCraftedAbilitySlot:GetCraftedAbilityId()
    return self.craftedAbilityId
end
function ZO_SharedCraftedAbilitySlot:GetControl()
    return self.control
end
function ZO_SharedCraftedAbilitySlot:IsSlotControl(slotControl)
    return self.control == slotControl
end
function ZO_SharedCraftedAbilitySlot:ShowDropCallout(isCorrectType)
    self.dropCallout:SetHidden(false)
    self.dropCallout:SetTexture(isCorrectType and self.dropCalloutTexturePositive or self.dropCalloutTextureNegative)
end
function ZO_SharedCraftedAbilitySlot:HideDropCallout()
    self.dropCallout:SetHidden(true)
end
ZO_SharedCraftedAbilityScriptSlot = ZO_InitializingCallbackObject:Subclass()
function ZO_SharedCraftedAbilityScriptSlot:Initialize(owner, control, emptyTexture, dropCalloutTexturePositive, dropCalloutTextureNegative, placeSound, removeSound, slotType, emptySlotIcon)
    ZO_InitializingCallbackObject.Initialize(self)
    self.owner = owner
    self.control = control
    control.slot = self
    self.emptyTexture = emptyTexture
    self.slotType = slotType
    if emptySlotIcon then
        self.emptyTexture = emptySlotIcon
        self.useEmptySlotIcon = true
        self.emptySlotOverrideIcon = self.control:GetNamedChild("EmptySlotIcon")
        internalassert(self.emptySlotOverrideIcon ~= nil)
    end
    self.nameLabel = control:GetNamedChild("Name")
    self.dropCalloutTexturePositive = dropCalloutTexturePositive
    self.dropCalloutTextureNegative = dropCalloutTextureNegative
    self.placeSound = placeSound
    self.removeSound = removeSound
    -- required
    self.slotIcon = self.control:GetNamedChild("Icon")
    self.dropCallout = self.control:GetNamedChild("DropCallout")
    -- optional
    self.iconBg = self.control:GetNamedChild("IconBg")
    self:ClearScriptId()
end
function ZO_SharedCraftedAbilityScriptSlot:SetScriptId(scriptId, isScriptCompatible, lockedColor)
    if self.scriptId == scriptId then
        return
    end
    local hadScriptId = self.scriptId and self.scriptId > 0
    self.scriptId = scriptId
    local scriptData = SCRIBING_DATA_MANAGER:GetCraftedAbilityScriptData(scriptId)
    local isEmpty = not scriptData
    if self.useEmptySlotIcon then
        if isEmpty and self.emptyTexture == "" then
            -- Empty string represents no icon, in this case we should just hide both inventory slot icon and our empty slot override
            self.emptySlotOverrideIcon:SetHidden(true)
            self.slotIcon:SetHidden(true)
        else
            self.emptySlotOverrideIcon:SetTexture(self.emptyTexture)
            self.emptySlotOverrideIcon:SetHidden(not isEmpty)
            if scriptData then
                self.slotIcon:SetTexture(scriptData:GetIcon())
            end
            self.slotIcon:SetHidden(isEmpty)
        end
    else
        self.slotIcon:SetHidden(false)
        if isEmpty then
            self.slotIcon:SetTexture(self.emptyTexture)
        else
            self.slotIcon:SetTexture(scriptData:GetIcon())
        end
    end
    if self.nameLabel then
        if not isEmpty then
            self.nameLabel:SetHidden(false)
            self.nameLabel:SetText(scriptData:GetFormattedName())
            local labelColor = ZO_SELECTED_TEXT
            if not isScriptCompatible then
                labelColor = ZO_ERROR_COLOR
            elseif not scriptData:IsUnlocked() then
                labelColor = lockedColor or ZO_DISABLED_TEXT
            end
            self.nameLabel:SetColor(labelColor:UnpackRGBA())
        else
            self.nameLabel:SetHidden(true)
        end
    end
    if self.iconBg then
        self.iconBg:SetHidden(self.scriptId == nil or self.scriptId == 0)
    end
    if self.scriptId ~= 0 then
        PlaySound(self.placeSound)
    elseif hadScriptId then
        PlaySound(self.removeSound)
    end
end
function ZO_SharedCraftedAbilityScriptSlot:ClearScriptId()
    local IS_COMPATIBLE = true
    self:SetScriptId(0, IS_COMPATIBLE)
end
function ZO_SharedCraftedAbilityScriptSlot:GetScriptId()
    return self.scriptId
end
function ZO_SharedCraftedAbilityScriptSlot:GetControl()
    return self.control
end
function ZO_SharedCraftedAbilityScriptSlot:IsSlotControl(slotControl)
    return self.control == slotControl
end
function ZO_SharedCraftedAbilityScriptSlot:ShowDropCallout(isCorrectType)
    self.dropCallout:SetHidden(false)
    self.dropCallout:SetTexture(isCorrectType and self.dropCalloutTexturePositive or self.dropCalloutTextureNegative)
end
function ZO_SharedCraftedAbilityScriptSlot:HideDropCallout()
    self.dropCallout:SetHidden(true)
end