local CONFIG_FILE = "slave.cfg" local MODEM_SIDE = "bottom" local config = { outputs = { straight = {}, cross = {}, }, defaultState = "straight", } local function saveConfig() local h = fs.open(CONFIG_FILE, "w") h.write(textutils.serialize(config)) h.close() end local function loadConfig() if not fs.exists(CONFIG_FILE) then saveConfig() return end local h = fs.open(CONFIG_FILE, "r") local raw = h.readAll() h.close() local t = textutils.unserialize(raw) if type(t) == "table" then config = t end end local function splitSides(text) local out = {} for part in string.gmatch((text or ""), "[^,%s]+") do if part ~= MODEM_SIDE then table.insert(out, part) end end return out end local function sideList(list) if not list or #list == 0 then return "(nincs)" end return table.concat(list, ",") end local function pulseTest(list) for _, side in ipairs({"top","left","right","front","back"}) do redstone.setOutput(side, false) end for _, side in ipairs(list) do redstone.setOutput(side, true) end sleep(1) for _, side in ipairs({"top","left","right","front","back"}) do redstone.setOutput(side, false) end end loadConfig() while true do term.setBackgroundColor(colors.black) term.setTextColor(colors.white) term.clear() term.setCursorPos(1,1) print("SLAVE SETUP") print("===========") print("Computer ID: " .. os.getComputerID()) print("Modem oldal: " .. MODEM_SIDE) print("Straight -> " .. sideList(config.outputs.straight)) print("Cross -> " .. sideList(config.outputs.cross)) print("Default -> " .. tostring(config.defaultState)) print("") print("1 - Straight oldalak beallitasa") print("2 - Cross oldalak beallitasa") print("3 - Default allapot") print("4 - Straight teszt") print("5 - Cross teszt") print("6 - Mentes") print("7 - Kilepes") print("") write("> ") local cmd = read() if cmd == "1" then write("Straight oldalak (pl: top,left): ") config.outputs.straight = splitSides(read()) elseif cmd == "2" then write("Cross oldalak (pl: right,back): ") config.outputs.cross = splitSides(read()) elseif cmd == "3" then write("Default (straight/cross): ") local v = read() if v == "straight" or v == "cross" then config.defaultState = v end elseif cmd == "4" then pulseTest(config.outputs.straight) elseif cmd == "5" then pulseTest(config.outputs.cross) elseif cmd == "6" then saveConfig() print("Mentve.") sleep(1) elseif cmd == "7" then term.clear() term.setCursorPos(1,1) print("Kilepes") break end end