-
Notifications
You must be signed in to change notification settings - Fork 7
Vault Reader API
Welcome to the CC: Vault API Guide make sure you are familiar with the CC API before attempting to use
The mod adds 1 peripheral called the Vault Reader. It has a single inventory slot, meant for vault gear or jewels. All functions provided by this API will read from the item inside the slot. The peripheral also works with the normal CC: Tweaked inventory peripheral API. The Vault Reader is intended to be used alongside that API, its recommended to use it to transfer items in and out of the correct places after reading, using the Vault Reader API with incorrect items will cause an error so you will need to use the inventory API to make sure the correct item is in (you can get the item name by using peripheral.getItemDetail(1).displayName()) or make sure not to transfer incorrect items in the first place.
Skip To Examples
getItemType()
Gets the type the item in the reader
-
stringThe Item Type can be one of"Charm","Trinket","Jewel","Inscription","Tool","Gear","Catalyst","Unknown" -
nilif the slot is empty
getToolDetails()
Gets the details of a Vault Tool in the reader
table a table of type Tool
nil if the slot is empty
- if the Item is not a vault Tool
getJewelDetails()
Gets the details of a Vault Jewel in the reader
table a table of type Jewel
nil if the slot is empty
- if the Item is not a Jewel
getGearDetails()
Gets the details of a Vault Gear in the reader
table a table of type UnidentifiedGear or Gear
nil if the slot is empty
- if the Item is not Gear
getInscriptionDetails()
Gets the details of a Inscription in the reader
table a table of type Inscription
nil if the slot is empty
- if the Item is not an Inscription
getCatalystDetails()
Gets the details of a Catalyst in the reader
table a table of type Catalyst
nil if the slot is empty
- if the Item is not an Catalyst
getTrinketDetails()
Gets the details of a Trinket in the reader
table a table of type Trinket
nil if the slot is empty
- if the Item is not an Trinket
reader.getItemLevel()
- integer the items level
reader.getRarity()
- Rarity rarity the item rarity in full caps:
reader.getRepairSlots()
- integer slots max repair slots of the item
reader.getUsedRepairSlots()
- integer slots the amount of repair slots that have been used on the item
reader.getImplicitCount()
- integer count the amount of implicit slots the item has
reader.getPrefixCount()
- integer count the amount of prefix slots the item has (including empty ones)
reader.getSuffixCount()
- integer count the amount of suffix slots the item has (including empty ones)
reader.getImplicits(index)
- (Modifier|RolledModifier)[]
reader.getPrefixes()
- (Modifier|RolledModifier)[]
reader.getSuffixes()
- (Modifier|RolledModifier)[]
- name
stringthe name of the item - type
"Tool" - level
integerThe Tool Level - rarity Rarity The Tool Rarity
- repairslots RepairSlots
- durability Durability
- implicits (Modifier)[]
- prefixes (Modifier)[]
- suffixes (Modifier)[]
string one of the following values
- SCRAPPY
- COMMON
- RARE
- EPIC
- OMEGA
- total
integerTotal Repair Slots - used
integerSlots Already Used Up
- total
integerTotal Durability - current
integerCurrent Durability
- name
stringThe modifier name - value
string | integer | numberThe value of the modifier - legendary
?booleanoptional, the Modifier is legendary - crafted
?booleanoptional, the Modifier is crafted - unusual
?booleanoptional, the Modifier is unusual - greater
?booleanoptional, the Modifier is greated - frozen
?booleanoptional, the Modifier is frozen
Extends Modifier for modifiers that have some form of roll information
- tier
integerThe rolled Tier - min
numberThe maximum possible roll for the modifier - max
numberThe minimum possible roll for the modifier
- name
stringthe name of the item - type
"Jewel" - level
integerThe Jewel Level - rarity Rarity The Jewel's Rarity
- implicits (Modifier|RolledModifier)[]
- prefixes (Modifier|RolledModifier)[]
- suffixes (Modifier|RolledModifier)[]
- name
stringthe name of the item - type
"Gear" - level
integerThe Tool Level - rarity Rarity The Gear's Rarity
- identified
falseIs The gear Identified
Identified Gear Has all the fields of UnidientifiedGear plus the following Attributes is the field that holds stuff that is in gear but isn't part of implicits for example base durability of an item, wether or not its soubound/living etc.
- identified
trueoverrides the one set by UnidientifiedGear - repairslots RepairSlots
- durability Durability
- attributes (Modifier|RolledModifier)[]
- implicits (Modifier|RolledModifier)[]
- prefixes (Modifier|RolledModifier)[]
- suffixes (Modifier|RolledModifier)[]
Optional fields are populated only if the trinket is identified
- identified
booleanIs the trinket Identified - name
?stringoptional,The name of the Trinket - uses
?integeroptional,The number of uses left in the trinket - slot
?stringoptional, The slot the trinket uses
- size
integerThe size of the Inscription - rooms
string[]The names of the rooms the Inscription adds
- size
integerThe size of the Catalyst - modifiers
string[]The resource Locations of the added vault effects eg: "the_vault:challenger_stack"
Optional fields are populated only if the charm is identified
- identified
booleanIs the charm Identified - god
?stringoptional,The God associated with the charm - uses
?integeroptional,The number of uses left in the charm - prefixes ?Modifier[] optional, The Prefixes on the Charm
What follows is a set of examples, they are not complete and serve as a starting point for your code
-- Example on how to get the size of a jewel in the reader
local function getJewelSize()
---@type vaultReader
local reader = peripheral.find("vaultreader")
if reader.getItemType() == "Jewel" then
local details = reader.getJewelDetails()
if details ~= nil then
for _, mod in ipairs(details.implicits) do
if mod.name == "Size" then
return mod.value
end
end
end
end
return nil
end-- This Function returns a list of the names of the suffixes in the puece of gear
local function getSuffixes()
---@type vaultReader
local reader = peripheral.find("vaultreader")
if reader.getItemType() == "Gear" then
local details = reader.getGearDetails()
local suffixes = {}
if details ~= nil and details.identified == true then
for _, mod in ipairs(details.suffixes) do
table.insert(suffixes, mod.name)
end
return suffixes
end
return nil
end
end```lua
--- Example on how to check if a gear piece has Souldbound on it
local function hasSoulbound()
---@type vaultReader
local reader = peripheral.find("vaultreader")
if reader.getItemType() == "Gear" then
local details = reader.getGearDetails()
if details ~= nil and details.identified == true then
for _, mod in ipairs(details.attributes) do
if mod.name == "Soulbound" then
return true
end
end
return false
end
return nil
end
end
if for example one wants to check if a modifier is legendary one can do
if mod.legendary then do_thing() end
--- Example on getting the max a each suffix could have rolled
local function getMaxRolls()
---@type vaultReader
local reader = peripheral.find("vaultreader")
local suffixes = {}
if reader.getItemType() == "Gear" then
local details = reader.getGearDetails()
if details ~= nil and details.identified == true then
for _, mod in ipairs(details.suffix) do
if mod.roll then
suffixes[mod.name] = mod.roll.max
end
end
return suffixes
end
return nil
end
end