tac.core.hardware v1.1.0

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.

Author: Twijn
View on GitHub →

Examples

-- 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

Functions

MyExtension.init()

View source

In your extension:

HardwareManager.findPeripheralsOfType(filter)

View source

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.

Parameters:
Returns: table Array of peripheral names matching the filter

HardwareManager.scanRFID(scannerName)

View source

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.

Parameters:
Returns: table|nil Array of badge tables with {data, distance}, or nil if scanner not found

HardwareManager.findClosestRFID(scannerName)

View source

Find the closest RFID badge Scans for RFID badges and returns the one with the smallest distance.

Parameters:
Returns: table|nil The closest badge {data, distance}, or nil if none found

HardwareManager.updateDoorSign(door)

View source

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

Parameters:

HardwareManager.updateDoorMonitor(door)

View source

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

Parameters:

HardwareManager.showDoorMonitorStatus(door, status, message, subtext)

View source

Show door status on monitor Displays a status message on the door monitor (for access granted/denied).

Parameters:

HardwareManager.showIdentityOnDoorMonitor(door, identity, status, distance)

View source

Show identity information on door monitor Displays comprehensive identity information during access attempts. Shows name, tags, access method, and status on door monitors.

Parameters:

HardwareManager.updateAllDisplays(doors)

View source

Update all door displays (signs and monitors) Iterates through all doors and updates their signs and monitors with current information.

Parameters:

HardwareManager.updateAllSigns(doors)

View source

Update all door signs Iterates through all doors and updates their signs with current information. For backwards compatibility - prefer updateAllDisplays for new code.

Parameters:

HardwareManager.showEnterAnimationMonitor(door, name, delay)

View source

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.

Parameters:

HardwareManager.showAccessDeniedMonitor(door, reason)

View source

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.

Parameters:

HardwareManager.showEnterAnimation(door, name, delay)

View source

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.

Parameters:

HardwareManager.showAccessDenied(door, reason)

View source

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.

Parameters:

HardwareManager.openDoorWithDisplay(door, name, openTime)

View source

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.

Parameters:

HardwareManager.controlDoor(door, state)

View source

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

Parameters:

HardwareManager.openDoor(door, name, openTime)

View source

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.

Parameters: