0
Web IDE main
10 commitsoaky Update cc-tweaked-storage
a818d30e 2026-09-25
| 2026-09-25 | |
| 2026-09-25 | |
| 2026-09-25 | |
| 2026-09-25 | |
| 2026-09-25 | |
main | 2026-09-25 |
| 2026-09-25 | |
| 2026-09-25 | |
| 2026-09-25 | |
| 2026-09-25 | |
| 2026-09-25 | |
| 2026-09-25 |
Overview
MITCc Tweaked Storage
Quick Install on your ComputerCraft device
Type this command in the terminal:
hub get cc-tweaked-storage
index.lua main
--[[
index.lua - reine In-Memory-Datenstruktur des Lagers.
Kennt KEINE Peripherals und ruft nichts in Minecraft auf -> dadurch
ausserhalb des Spiels testbar. Der Store (store.lua) fuettert diesen
Index mit dem, was er per list()/getItemDetail() aus den Chests liest.
Schluessel ("key") ist NBT-bewusst:
- normale Items: "minecraft:cobblestone"
- Items mit NBT (Buch etc): "minecraft:enchanted_book@<hash>"
Gleiche Items teilen sich denselben key (stapeln zusammen), verschiedene
NBT-Varianten bekommen eigene keys (werden nicht mehr vermischt).
Interne Form:
items[key] = {
name, nbt, displayName, enchantments, count,
chests = { [chestName] = { [slot] = count } },
}
slotOwner[chest][slot] = key -- Rueckwaertskarte fuer slot-genaue Updates
]]
local Index = {}
Index.__index = Index
function Index.new()
return setmetatable({
items = {},
slotOwner = {},
}, Index)
end
-- NBT-bewusster Schluessel aus einem list()/Item-Eintrag.
function Index.keyOf(item)
if item.nbt and item.nbt ~= "" then
return item.name .. "@" .. item.nbt
end
return item.name
end
-- Entfernt den Inhalt EINES Slots aus dem Index (falls dort etwas bekannt war).
function Index:clearSlot(chest, slot)
local owners = self.slotOwner[chest]
local key = owners and owners[slot]
if not key then return end
local entry = self.items[key]
if entry then
local perChest = entry.chests[chest]
local c = perChest and perChest[slot]
if c then
entry.count = entry.count - c
perChest[slot] = nil
if next(perChest) == nil then entry.chests[chest] = nil end
if entry.count <= 0 or next(entry.chests) == nil then
self.items[key] = nil
end
end
end
owners[slot] = nil
if next(owners) == nil then self.slotOwner[chest] = nil end
end
-- Setzt den Inhalt EINES Slots (ersetzt vorher Bekanntes im selben Slot).
function Index:setSlot(chest, slot, key, name, nbt, count, displayName, enchantments)
self:clearSlot(chest, slot)
if not key or count <= 0 then return end
local entry = self.items[key]
if not entry then
entry = { name = name, nbt = nbt, displayName = displayName or name, enchantments = enchantments, count = 0, chests = {} }
self.items[key] = entry
else
if displayName then entry.displayName = displayName end
entry.enchantments = enchantments
end
entry.chests[chest] = entry.chests[chest] or {}
entry.chests[chest][slot] = count
entry.count = entry.count + count
self.slotOwner[chest] = self.slotOwner[chest] or {}
self.slotOwner[chest][slot] = key
end
-- Entfernt eine komplette Chest (z.B. wenn sie abgebaut/getrennt wurde).
function Index:clearChest(chest)
local owners = self.slotOwner[chest]
if not owners then return end
local slots = {}
for slot in pairs(owners) do slots[#slots + 1] = slot end
for _, slot in ipairs(slots) do
self:clearSlot(chest, slot)
end
end
function Index:get(key)
return self.items[key]
end
-- Liste aller Items fuer die GUI.
function Index:query()
local out = {}
for key, e in pairs(self.items) do
out[#out + 1] = { key = key, name = e.name, nbt = e.nbt, displayName = e.displayName, count = e.count, enchantments = e.enchantments }
end
return out
end
-- Anzahl verschiedener Sorten und Gesamtmenge.
function Index:stats()
local distinct, total = 0, 0
for _, e in pairs(self.items) do
distinct = distinct + 1
total = total + e.count
end
return distinct, total
end
-- Summen je Item-Name (ueber alle NBT-Varianten) - fuer die Watchlist.
function Index:totalsByName()
local t = {}
for _, e in pairs(self.items) do
t[e.name] = (t[e.name] or 0) + e.count
end
return t
end
-- Ein Anzeige-Name zu einer Item-ID (erste passende Variante) - fuer Warnungen.
function Index:displayNameForName(name)
for _, e in pairs(self.items) do
if e.name == name then return e.displayName end
end
return nil
end
return Index Usage
Once installed with hub get cc-tweaked-storage, run:
cc-tweaked-storageCareful what you run: This script was written by oaky, not by us.
It runs with full access to the computer you install it on — it can read and delete files there.
Read it before you run it.
About
No description provided.
MIT License
★ 0 stars
1 in-game downloads
Hardware Targets
computer