Handles peripheral detection, door control, and sign updates for the TAC system. Provides utilities for finding and interacting with ComputerCraft peripherals. Supports NFC readers, RFID scanners, monitors, and signs for door displays.
View on GitHub →-- In your extension:
function MyExtension.init(tac)
local Hardware = require("tac.core.hardware")
-- Open a door by ID
Hardware.openDoor("tenant_door_1")
-- Find all NFC readers
local readers = Hardware.findPeripheralsOfType("nfc_reader")
for _, reader in ipairs(readers) do
print("Found reader: " .. reader)
end
-- Find all RFID scanners
local rfidScanners = Hardware.findPeripheralsOfType("rfid_scanner")
for _, scanner in ipairs(rfidScanners) do
print("Found RFID scanner: " .. scanner)
end
-- Update a sign after access
Hardware.updateSign("back", "Access Granted", "Welcome!")
-- Show access animations
Hardware.showEnterAnimation()
Hardware.showDenyAnimation()
end
HardwareManager.findPeripheralsOfType(filter)Find peripherals of a specific type Searches all connected peripherals and returns a list of names matching the specified type. Useful for finding NFC readers, RFID scanners, modems, monitors, etc.
filter (string): The peripheral type to search for (e.g., "nfc_reader", "rfid_scanner", "modem", "monitor")HardwareManager.scanRFID(scannerName)Scan for RFID badges in range Uses an RFID scanner to find badges in the area. Returns a list of detected badges with their data and distance.
scannerName (string): The name of the RFID scanner peripheralHardwareManager.findClosestRFID(scannerName)Find the closest RFID badge Scans for RFID badges and returns the one with the smallest distance.
scannerName (string): The name of the RFID scanner peripheralHardwareManager.updateDoorSign(door)Update a door sign with door information Updates a sign peripheral to display the door name and tags. The sign will show the door name on line 2 with decorative borders. - sign (string): Peripheral name of the sign - name (string): Door name to display - tags (table): Array of tag strings
door (table): Door configuration with fields:HardwareManager.updateDoorMonitor(door)Update door monitor with door information Updates a monitor peripheral to display the door name, tags, and status. Adapts display based on monitor size. - monitor (string): Peripheral name of the monitor - name (string): Door name to display - tags (table): Array of tag strings
door (table): Door configuration with fields:HardwareManager.showDoorMonitorStatus(door, status, message, subtext)Show door status on monitor Displays a status message on the door monitor (for access granted/denied).
door (table): Door configuration with monitor fieldstatus (string): "granted" or "denied"message (string): Message to displaysubtext (string|nil): Optional subtext (e.g., person's name)HardwareManager.showIdentityOnDoorMonitor(door, identity, status, distance)Show identity information on door monitor Displays comprehensive identity information during access attempts. Shows name, tags, access method, and status on door monitors.
door (table): Door configuration with monitor fieldidentity (table): Identity data with name, tags, etc.status (string): "scanning", "granted", "denied", "expired", etc.distance (number|nil): Optional distance for RFID scansHardwareManager.updateAllDisplays(doors)Update all door displays (signs and monitors) Iterates through all doors and updates their signs and monitors with current information.
doors (table): Persistent doors storage object with .getAll() methodHardwareManager.updateAllSigns(doors)Update all door signs Iterates through all doors and updates their signs with current information. For backwards compatibility - prefer updateAllDisplays for new code.
doors (table): Persistent doors storage object with .getAll() methodHardwareManager.showEnterAnimationMonitor(door, name, delay)Show enter animation on monitors Displays a welcome animation on a door's monitor, gradually revealing the user's name. After the animation completes, restores the monitor to its normal state.
door (table): Door configuration with monitor peripheralname (string): Name to display in the welcome messagedelay (number): Total animation duration in secondsHardwareManager.showAccessDeniedMonitor(door, reason)Show access denied animation on monitor Displays a flashing "ACCESS DENIED" message on a door's monitor with a custom reason. The message flashes before restoring the monitor to its normal state.
door (table): Door configuration with monitor peripheralreason (string|nil): Reason for denial (defaults to "ACCESS DENIED")HardwareManager.showEnterAnimation(door, name, delay)Show enter animation on signs Displays a welcome animation on a door's sign, gradually revealing the user's name. After the animation completes, restores the sign to its normal state.
door (table): Door configuration with sign peripheralname (string): Name to display in the welcome messagedelay (number): Total animation duration in secondsHardwareManager.showAccessDenied(door, reason)Show access denied message on door sign Displays a flashing "ACCESS DENIED" message on a door's sign with a custom reason. The message flashes 3 times before restoring the sign to its normal state. Also shows on monitor if present.
door (table): Door configuration with sign peripheralreason (string|nil): Reason for denial (defaults to "ACCESS DENIED")HardwareManager.openDoorWithDisplay(door, name, openTime)Open door with combined display animation Opens a door, optionally displays a welcome animation on all displays, then automatically closes it. The door will remain open for the specified duration or the door's default open time. Works with both signs and monitors.
door (table): Door configurationname (string|nil): User name to display in animation (nil to skip animation)openTime (number|nil): Time in seconds to keep door open (defaults to door.openTime or DEFAULT_OPEN_TIME)HardwareManager.controlDoor(door, state)Control door relay (open/close) Sets the redstone output state for all sides of a door's relay peripheral. Used to physically open or close doors connected via redstone. - relay (string): Peripheral name of the redstone relay
door (table): Door configuration with fields:state (boolean): true to activate relay (open door), false to deactivate (close door)HardwareManager.openDoor(door, name, openTime)Open door for specified time Opens a door, optionally displays a welcome animation, then automatically closes it. The door will remain open for the specified duration or the door's default open time. Supports both signs and monitors for display.
door (table): Door configurationname (string|nil): User name to display in animation (nil to skip animation)openTime (number|nil): Time in seconds to keep door open (defaults to door.openTime or DEFAULT_OPEN_TIME)