minor changes
This commit is contained in:
@ -25,7 +25,10 @@ config.canAccessHazardGates = true
|
||||
config.irisEnabled = true
|
||||
config.autoCloseIrisOnIncoming = true
|
||||
config.irisCloseDelay = 0.1 -- seconds before closing iris on incoming
|
||||
config.autoOpenIrisAfterDisconnect = true
|
||||
|
||||
-- Default iris state when gate is idle (no connection)
|
||||
-- true = iris closed when idle, false = iris open when idle
|
||||
config.irisClosedByDefault = false
|
||||
|
||||
-- Iris password (set to nil to disable remote password unlock)
|
||||
config.irisPassword = "1234"
|
||||
|
||||
18
display.lua
18
display.lua
@ -139,7 +139,7 @@ function display.selectionTabs()
|
||||
term.redirect(oldterm)
|
||||
end
|
||||
|
||||
function display.showIncoming(addressString, allowed, reason)
|
||||
function display.showIncoming(addressName, addressString, allowed, reason)
|
||||
mon.setBackgroundColor(colors.black)
|
||||
mon.clear()
|
||||
|
||||
@ -159,9 +159,19 @@ function display.showIncoming(addressString, allowed, reason)
|
||||
|
||||
mon.setCursorPos(1, 6)
|
||||
mon.setBackgroundColor(colors.black)
|
||||
mon.write("Address:")
|
||||
mon.setCursorPos(1, 7)
|
||||
mon.write(addressString)
|
||||
|
||||
-- Show name if found in address book
|
||||
if addressName then
|
||||
mon.write("Name: " .. addressName)
|
||||
mon.setCursorPos(1, 7)
|
||||
mon.write("Address:")
|
||||
mon.setCursorPos(1, 8)
|
||||
mon.write(addressString)
|
||||
else
|
||||
mon.write("Address:")
|
||||
mon.setCursorPos(1, 7)
|
||||
mon.write(addressString)
|
||||
end
|
||||
end
|
||||
|
||||
function display.showEntity(entityType, entityName, allowed)
|
||||
|
||||
@ -145,7 +145,10 @@ function handlers.handleDisconnect(eventType, side, disCode)
|
||||
redstone.setOutput("top", false)
|
||||
utils.log("Stargate disconnected (code: " .. tostring(disCode) .. ")")
|
||||
|
||||
if config.autoOpenIrisAfterDisconnect then
|
||||
-- Set iris to default state
|
||||
if config.irisClosedByDefault then
|
||||
utils.closeIris()
|
||||
else
|
||||
utils.openIris()
|
||||
end
|
||||
|
||||
|
||||
41
startup.lua
41
startup.lua
@ -59,9 +59,13 @@ handlers.init(config, gate, mon, utils, display, events)
|
||||
-- Ensure gate starts disconnected
|
||||
gate.disconnectStargate()
|
||||
|
||||
-- Ensure iris starts open
|
||||
-- Set iris to default state
|
||||
if config.irisEnabled then
|
||||
gate.openIris()
|
||||
if config.irisClosedByDefault then
|
||||
gate.closeIris()
|
||||
else
|
||||
gate.openIris()
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------
|
||||
@ -243,6 +247,32 @@ end
|
||||
-- INCOMING WORMHOLE HANDLER
|
||||
---------------------------------------------
|
||||
|
||||
local function findAddressName(address)
|
||||
-- Search all address categories for matching address
|
||||
local categories = {addresses.MainGates, addresses.playerGates, addresses.hazardGates}
|
||||
|
||||
for _, category in ipairs(categories) do
|
||||
for _, entry in ipairs(category) do
|
||||
local name, storedAddress = entry[1], entry[2]
|
||||
-- Compare addresses (excluding point of origin)
|
||||
if #address == #storedAddress then
|
||||
local match = true
|
||||
for i = 1, #address do
|
||||
if address[i] ~= storedAddress[i] then
|
||||
match = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if match then
|
||||
return name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil -- Not found in address book
|
||||
end
|
||||
|
||||
local function handleIncomingWormhole()
|
||||
local state = getState()
|
||||
|
||||
@ -261,11 +291,14 @@ local function handleIncomingWormhole()
|
||||
-- Check security
|
||||
local allowed, reason = utils.isAddressAllowed(state.incomingAddress)
|
||||
local addressString = gate.addressToString(state.incomingAddress) or "Unknown"
|
||||
|
||||
-- Look up address name in address book
|
||||
local addressName = findAddressName(state.incomingAddress)
|
||||
|
||||
utils.log("Incoming wormhole from: " .. addressString .. " " .. reason)
|
||||
utils.log("Incoming wormhole from: " .. (addressName or addressString) .. " " .. reason)
|
||||
|
||||
-- Show incoming connection status
|
||||
display.showIncoming(addressString, allowed, reason)
|
||||
display.showIncoming(addressName, addressString, allowed, reason)
|
||||
|
||||
-- Send version message to remote gate
|
||||
sleep(0.5) -- Brief delay to ensure connection is stable
|
||||
|
||||
Reference in New Issue
Block a user