Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Read Redstone
- --NuAoA
- local sig_names = {"White","Orange","Magenta","LightBlue","Yellow","Lime","Pink","Gray","LightGray","Cyan","Purple","Blue","Brown","Green","Red","Black"}
- local sig_values = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768}
- local on_array = {}
- os.pullEvent = os.pullEventRaw
- local mod_array = {
- "Anon232"; --White
- "USCCoder"; --Orange
- "Canilsen"; --Magenta
- "Cynterea"; --LightBlue
- "Daebat"; --Yellow
- "Drehmini"; --Lime
- "Brendan09"; --Pink
- "Sonolumin"; --Gray
- "Sega5"; --LightGray
- "Awade33"; --Cyan
- "k"; --Purple
- "k"; --Blue
- "k"; --Brown
- "k"; --Green
- "k"; --Red
- "k"; --Black
- }
- for i=1,16 do
- local temp_tab = {}
- temp_tab["name"] = mod_array[i]
- temp_tab["state"] = false
- on_array[i] = temp_tab
- end
- function deepcopy(orig)
- local orig_type = type(orig)
- local copy
- if orig_type == 'table' then
- copy = {}
- for orig_key, orig_value in next, orig, nil do
- copy[deepcopy(orig_key)] = deepcopy(orig_value)
- end
- setmetatable(copy, deepcopy(getmetatable(orig)))
- else -- number, string, boolean, etc
- copy = orig
- end
- return copy
- end
- function decode(value)
- local tab = {}
- for i=16,1,-1 do
- if value>=sig_values[i] then
- value = value - sig_values[i]
- tab[i] = true
- end
- end
- return tab
- end
- function broadcast()
- rednet.open("front")
- while true do
- local event = os.pullEvent("sendTable")
- local str = ""
- for i=1,16 do
- str = str..on_array[i]["name"]
- if on_array[i]["state"] then
- str = str.."|on "
- else
- str = str.."|off "
- end
- end
- rednet.broadcast(str)
- print(str)
- end
- end
- function update()
- while true do
- local event = os.pullEvent("redstone")
- local temp_tab = decode(rs.getBundledInput("right"))
- for i=1,16 do
- on_array[i]["state"] = temp_tab[i]
- end
- os.queueEvent("sendTable")
- end
- end
- function antiHack()
- print("[AntiHack] Enabled")
- while true do
- local event,side = os.pullEventRaw()
- if event == "peripheral" then
- if peripheral.getType(side) == "drive" then
- -- we got someone putting a drive next to the terminal
- elseif peripheral.getType(side) == "computer" then
- end
- elseif event == "disk" then
- if fs.exists("disk/startup") then
- fs.delete("disk/startup")
- disk.setLabel(side,"Broken Floppy")
- end
- elseif event == "terminate" then
- os.queueEvent("password")
- end
- end
- end
- function password()
- while true do
- local event = os.pullEvent("password")
- sleep(0)
- term.clear()
- term.setCursorPos(1,1)
- if string.lower(read("*")) == "recordmods" then
- shell.run("edit startup")
- os.reboot()
- end
- end
- end
- parallel.waitForAll(update,broadcast,password,antiHack)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement