-
Notifications
You must be signed in to change notification settings - Fork 5
/
spec-06-scripting.lua
45 lines (35 loc) · 929 Bytes
/
spec-06-scripting.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
--
-- Scripting example:
-- Create a Corpo Glasses for every legendary clothing mod with that mod in each slot.
--
-- This opens access to the mod functions
local ctx = ...
-- Load TweakDb class to access metadata
local TweakDb = ctx.require("mod/helpers/TweakDb")
-- Create instance and load the metadata
local tweakDb = TweakDb:new(true)
-- Table to store our items
local backpack = {}
-- Iterate every legendary clothing mod
for _, mod in tweakDb:filter({ kind = "Mod", group = "Clothing", quality = "Legendary" }) do
-- Item spec with slots container
local glasses = {
id = "Corporate_01_Set_Glasses",
slots = {}
}
-- Put mod in every mod slot
for index = 1, 3 do
table.insert(glasses.slots, {
slot = "Mod" .. index,
id = mod.id,
})
end
-- Add to the table
table.insert(backpack, glasses)
end
-- Free database resources
tweakDb:unload()
-- Return the final spec
return {
Backpack = backpack
}