minor changes
This commit is contained in:
@ -25,7 +25,10 @@ config.canAccessHazardGates = true
|
|||||||
config.irisEnabled = true
|
config.irisEnabled = true
|
||||||
config.autoCloseIrisOnIncoming = true
|
config.autoCloseIrisOnIncoming = true
|
||||||
config.irisCloseDelay = 0.1 -- seconds before closing iris on incoming
|
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)
|
-- Iris password (set to nil to disable remote password unlock)
|
||||||
config.irisPassword = "1234"
|
config.irisPassword = "1234"
|
||||||
|
|||||||
18
display.lua
18
display.lua
@ -139,7 +139,7 @@ function display.selectionTabs()
|
|||||||
term.redirect(oldterm)
|
term.redirect(oldterm)
|
||||||
end
|
end
|
||||||
|
|
||||||
function display.showIncoming(addressString, allowed, reason)
|
function display.showIncoming(addressName, addressString, allowed, reason)
|
||||||
mon.setBackgroundColor(colors.black)
|
mon.setBackgroundColor(colors.black)
|
||||||
mon.clear()
|
mon.clear()
|
||||||
|
|
||||||
@ -159,9 +159,19 @@ function display.showIncoming(addressString, allowed, reason)
|
|||||||
|
|
||||||
mon.setCursorPos(1, 6)
|
mon.setCursorPos(1, 6)
|
||||||
mon.setBackgroundColor(colors.black)
|
mon.setBackgroundColor(colors.black)
|
||||||
mon.write("Address:")
|
|
||||||
mon.setCursorPos(1, 7)
|
-- Show name if found in address book
|
||||||
mon.write(addressString)
|
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
|
end
|
||||||
|
|
||||||
function display.showEntity(entityType, entityName, allowed)
|
function display.showEntity(entityType, entityName, allowed)
|
||||||
|
|||||||
@ -145,7 +145,10 @@ function handlers.handleDisconnect(eventType, side, disCode)
|
|||||||
redstone.setOutput("top", false)
|
redstone.setOutput("top", false)
|
||||||
utils.log("Stargate disconnected (code: " .. tostring(disCode) .. ")")
|
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()
|
utils.openIris()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
41
startup.lua
41
startup.lua
@ -59,9 +59,13 @@ handlers.init(config, gate, mon, utils, display, events)
|
|||||||
-- Ensure gate starts disconnected
|
-- Ensure gate starts disconnected
|
||||||
gate.disconnectStargate()
|
gate.disconnectStargate()
|
||||||
|
|
||||||
-- Ensure iris starts open
|
-- Set iris to default state
|
||||||
if config.irisEnabled then
|
if config.irisEnabled then
|
||||||
gate.openIris()
|
if config.irisClosedByDefault then
|
||||||
|
gate.closeIris()
|
||||||
|
else
|
||||||
|
gate.openIris()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
@ -243,6 +247,32 @@ end
|
|||||||
-- INCOMING WORMHOLE HANDLER
|
-- 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 function handleIncomingWormhole()
|
||||||
local state = getState()
|
local state = getState()
|
||||||
|
|
||||||
@ -262,10 +292,13 @@ local function handleIncomingWormhole()
|
|||||||
local allowed, reason = utils.isAddressAllowed(state.incomingAddress)
|
local allowed, reason = utils.isAddressAllowed(state.incomingAddress)
|
||||||
local addressString = gate.addressToString(state.incomingAddress) or "Unknown"
|
local addressString = gate.addressToString(state.incomingAddress) or "Unknown"
|
||||||
|
|
||||||
utils.log("Incoming wormhole from: " .. addressString .. " " .. reason)
|
-- Look up address name in address book
|
||||||
|
local addressName = findAddressName(state.incomingAddress)
|
||||||
|
|
||||||
|
utils.log("Incoming wormhole from: " .. (addressName or addressString) .. " " .. reason)
|
||||||
|
|
||||||
-- Show incoming connection status
|
-- Show incoming connection status
|
||||||
display.showIncoming(addressString, allowed, reason)
|
display.showIncoming(addressName, addressString, allowed, reason)
|
||||||
|
|
||||||
-- Send version message to remote gate
|
-- Send version message to remote gate
|
||||||
sleep(0.5) -- Brief delay to ensure connection is stable
|
sleep(0.5) -- Brief delay to ensure connection is stable
|
||||||
|
|||||||
Reference in New Issue
Block a user