Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Written by rahph.
- --Send nukes I mean nudes
- --Anyway, config
- local sV = "Unofficial 1.10B"
- local tape0 = peripheral.wrap("tape_drive_7")
- local tape1 = peripheral.wrap("tape_drive_6")
- local tape2 = peripheral.wrap("tape_drive_5")
- local tape3 = peripheral.wrap("tape_drive_4")
- local floor = peripheral.wrap("monitor_30")
- --End config. Dont alter the program beyond this line unless you know what ya doin
- local oldwrite = nil
- local oldbg = nil
- local oldfg = nil
- local lampConnected = 0
- local function rewrite()
- oldwrite = mon.write
- oldbg = mon.setBackgroundColor
- oldfg = mon.setTextColor
- mon.write = function(text) oldwrite(text) sleep(0.05) end
- mon.setBackgroundColor = function(col) oldbg(col) sleep(0.05) end
- mon.setTextColor = function(col) oldfg(col) sleep(0.05) end
- end
- local function play(id)
- if id == 1 then tape0.play() end
- if id == 2 then tape1.play() end
- if id == 3 then tape2.play() end
- if id == 4 then tape3.play() end
- end
- local err = {}
- err["mt"] = {}
- err["lt"] = {}
- function errorReport()
- mon.setTextScale(0.5)
- x,y = mon.getSize()
- mon.setPaletteColor(colors.blue,0x0000FF)
- mon.setPaletteColor(colors.white,0xFFFFFF)
- mon.clear()
- mon.setBackgroundColor(colors.blue)
- mon.clear()
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,2)
- mon.setPaletteColor(colors.gray,0x99AAB5)
- mon.setTextColor(colors.gray)
- for i=1,x do mon.write("\127") end
- mon.setCursorPos(1,1)
- for i=1,x do mon.write("\127") end
- mon.setCursorPos(1,3)
- for i=1,x do mon.write("\127") end
- mon.setTextColor(colors.white)
- mon.setCursorPos((x-16)/2+1,2)
- mon.write(" DISCO CONTROLL ")
- mon.setCursorPos(3,4)
- mon.write("The program has ran into an issue")
- mon.setCursorPos(3,5)
- mon.write("The following is an error report given to us.")
- mon.setCursorPos(3,6)
- if err["mt"][1] ~= nil then
- mon.write(err["mt"][2] .. " @ Main thread")
- end
- if err["lt"][1] ~= nil then
- mon.write(err["lt"][2] .. " @ Lamp thread")
- end
- mon.setCursorPos(3,y-1)
- mon.write("Thats all we know")
- mon.setCursorPos(3,9)
- mon.write("Dumping report...")
- mon.setCursorPos(3,10)
- fname = "DiscoCrash" .. "-" .. os.day() .. "-" .. textutils.formatTime(os.time())
- mon.write("File name: " .. fname)
- mon.setCursorPos(3,11)
- mon.write("[##")
- oFile = fs.open(fname,"w")
- mon.write("####")
- oFile.write(textutils.serialise(err))
- mon.write("######")
- oFile.flush()
- mon.write("###")
- oFile.close()
- mon.write("###]")
- mon.setCursorPos(3,12)
- mon.write("Thats all we know")
- mon.setCursorPos(3,y-1)
- mon.write("Restarting in 2 seconds")
- mon.setCursorPos(1,y)
- for i=1,x do sleep(2/x) mon.write("X") end
- end
- local function rewind(id)
- if id == 1 then tape0.seek(-tape0.getSize()) end
- if id == 2 then tape1.seek(-tape1.getSize()) end
- if id == 3 then tape2.seek(-tape2.getSize()) end
- if id == 4 then tape3.seek(-tape3.getSize()) end
- end
- local function pause(id)
- if id == 1 then tape0.stop() end
- if id == 2 then tape1.stop() end
- if id == 3 then tape2.stop() end
- if id == 4 then tape3.stop() end
- end
- local function round(num, n)
- local mult = 10^(n or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- mon = peripheral.wrap("top")
- function redraw(vol,speed,light)
- mon.setTextScale(1)
- x,y = mon.getSize()
- local objloc = {}
- objloc["tape"] = {}
- objloc.tape[1] = {}
- objloc.tape[1]["volume"] = {up=0,down=0}
- objloc.tape[1]["speed"] = {up=0,down=0}
- objloc.tape[1]["ctrlr"] = {0,0}
- objloc.tape[2] = {}
- objloc.tape[2]["volume"] = {up=0,down=0}
- objloc.tape[2]["speed"] = {up=0,down=0}
- objloc.tape[2]["ctrlr"] = {0,0}
- objloc.tape[3] = {}
- objloc.tape[3]["volume"] = {up=0,down=0}
- objloc.tape[3]["speed"] = {up=0,down=0}
- objloc.tape[3]["ctrlr"] = {0,0}
- objloc.tape[4] = {}
- objloc.tape[4]["volume"] = {up=0,down=0}
- objloc.tape[4]["speed"] = {up=0,down=0}
- objloc.tape[4]["ctrlr"] = {0,0}
- objloc.tape[1]["ctrlr"]["back"] = {4,4}
- objloc.tape[1]["ctrlr"]["stop"] = {4,5}
- objloc.tape[1]["ctrlr"]["play"] = {4,6}
- objloc.tape[2]["ctrlr"]["back"] = {28,4}
- objloc.tape[2]["ctrlr"]["stop"] = {28,5}
- objloc.tape[2]["ctrlr"]["play"] = {28,6}
- objloc.tape[3]["ctrlr"]["back"] = {4,11}
- objloc.tape[3]["ctrlr"]["stop"] = {4,12}
- objloc.tape[3]["ctrlr"]["play"] = {4,13}
- objloc.tape[4]["ctrlr"]["back"] = {28,11}
- objloc.tape[4]["ctrlr"]["stop"] = {28,12}
- objloc.tape[4]["ctrlr"]["play"] = {28,13}
- objloc.light = {}
- mon.setPaletteColor(colors.blue,0x23272A)
- mon.setPaletteColor(colors.white,0xFFFFFF)
- mon.clear()
- mon.setBackgroundColor(colors.blue)
- mon.clear()
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,2)
- mon.setPaletteColor(colors.gray,0x99AAB5)
- mon.setTextColor(colors.gray)
- for i=1,x do mon.write("\127") end
- mon.setCursorPos(1,1)
- for i=1,x do mon.write("\127") end
- mon.setCursorPos(1,3)
- for i=1,x do mon.write("\127") end
- mon.setTextColor(colors.white)
- mon.setCursorPos((x-16)/2+1,2)
- mon.write(" DISCO CONTROLL ")
- mon.setCursorPos(((x/2)-6)/2,4)
- mon.write("TAPE 0")
- mon.setCursorPos(4,4)
- mon.write("\17")
- mon.setCursorPos(4,5)
- mon.write("\143")
- mon.setCursorPos(4,6)
- mon.write("\16")
- mon.setCursorPos((((x/2)-6)/2)+(x/2),4)
- mon.write("TAPE 1")
- mon.setCursorPos(28,4)
- mon.write("\17")
- mon.setCursorPos(28,5)
- mon.write("\143")
- mon.setCursorPos(28,6)
- mon.write("\16")
- mon.setCursorPos(((x/2)-6)/2,11)
- mon.write("TAPE 2")
- mon.setCursorPos(4,11)
- mon.write("\17")
- mon.setCursorPos(4,12)
- mon.write("\143")
- mon.setCursorPos(4,13)
- mon.write("\16")
- mon.setCursorPos((((x/2)-6)/2)+(x/2),11)
- mon.write("TAPE 3")
- mon.setCursorPos(28,11)
- mon.write("\17")
- mon.setCursorPos(28,12)
- mon.write("\143")
- mon.setCursorPos(28,13)
- mon.write("\16")
- mon.setTextColor(colors.gray)
- for i=4,y do mon.setCursorPos(25,i) mon.write("\127\127") end
- mon.setTextColor(colors.white)
- objloc.light = {((x/2)-10/2)+9,18}
- if lampConnected == 1 then
- mon.setCursorPos((x/2)-10/2,18)
- mon.write("LIGHTS [")
- if light == 0 then mon.setTextColor(colors.red) mon.write("X") mon.setTextColor(colors.white) end
- if light == 1 then mon.setTextColor(colors.orange) mon.write("-") mon.setTextColor(colors.white) end
- if light == 2 then mon.setTextColor(colors.lime) mon.write("V") mon.setTextColor(colors.white) end
- mon.write("]")
- else
- mon.setCursorPos((x/2)-15/2,18)
- mon.write("NO LIGHTS FOUND")
- end
- mon.setTextColor(colors.gray)
- mon.setCursorPos(1,19)
- for i=1,x do mon.write("\127") end
- for i=1,y do mon.setCursorPos(1,i) mon.write("\127\127") end
- for i=1,y do mon.setCursorPos(x-1,i) mon.write("\127\127") end
- mon.setCursorPos(1,10)
- --for i=1,x do mon.write("\127") end
- --mon.setCursorPos(1,11)
- for i=1,x do mon.write("\127") end
- mon.setCursorPos(1,17)
- for i=1,x do mon.write("\127") end
- mon.setCursorPos(x-#sV+1,y)
- mon.write(sV)
- mon.setCursorPos(((x/2)-6)/2,6)
- mon.write("VOLUME")
- mon.setCursorPos(((x/2)-6)/2,8)
- mon.write("SPEED:")
- mon.setCursorPos((((x/2)-6)/2)+(x/2),6)
- mon.write("VOLUME")
- mon.setCursorPos((((x/2)-6)/2)+(x/2),8)
- mon.write("SPEED:")
- mon.setCursorPos(((x/2)-6)/2,13)
- mon.write("VOLUME")
- mon.setCursorPos(((x/2)-6)/2,15)
- mon.write("SPEED:")
- mon.setCursorPos((((x/2)-6)/2)+(x/2),13)
- mon.write("VOLUME")
- mon.setCursorPos((((x/2)-6)/2)+(x/2),15)
- mon.write("SPEED:")
- mon.setBackgroundColor(colors.white)
- objloc.tape[1].volume.down = {((x/2)-8)/2-0.5,7}
- objloc.tape[1].volume.up = {objloc.tape[1].volume.down[1] + 7,7}
- mon.setPaletteColor(colors.yellow,0x7289DA)
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.white)
- mon.setCursorPos(objloc.tape[1].volume.down[1],7)
- mon.write("\171 \187")
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.black)
- mon.setCursorPos(((x/2)-6)/2,7)
- mon.write(" ")
- if #tostring(vol[1]) % 2 == 1 then
- mon.setCursorPos(((x/2)-#tostring(vol[1]))/2-1,7)
- else
- mon.setCursorPos(((x/2)-#tostring(vol[1]))/2,7)
- end
- mon.write(vol[1])
- mon.setBackgroundColor(colors.white)
- objloc.tape[1].speed.down = {((x/2)-8)/2-0.5,9}
- objloc.tape[1].speed.up = {objloc.tape[1].speed.down[1] + 7,9}
- mon.setPaletteColor(colors.yellow,0x7289DA)
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.white)
- mon.setCursorPos(objloc.tape[1].speed.down[1],9)
- mon.write("\171 \187")
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.black)
- mon.setCursorPos(((x/2)-6)/2,9)
- mon.write(" ")
- if #tostring(speed[1]) % 2 == 1 then
- mon.setCursorPos(((x/2)-#tostring(speed[1]))/2-1,9)
- else
- mon.setCursorPos(((x/2)-#tostring(speed[1]))/2,9)
- end
- mon.write(speed[1])
- mon.setBackgroundColor(colors.white)
- objloc.tape[2].volume.down = {(((x/2)-8)/2)+(x/2)-0.5,7}
- objloc.tape[2].volume.up = {objloc.tape[2].volume.down[1] + 7,7}
- mon.setPaletteColor(colors.yellow,0x7289DA)
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.white)
- mon.setCursorPos(objloc.tape[2].volume.down[1],7)
- mon.write("\171 \187")
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.black)
- mon.setCursorPos((((x/2)-6)/2)+(x/2),7)
- mon.write(" ")
- if #tostring(vol[2]) % 2 == 1 then
- mon.setCursorPos((((x/2)-#tostring(vol[2]))/2-1)+(x/2),7)
- else
- mon.setCursorPos((((x/2)-#tostring(vol[2]))/2)+(x/2),7)
- end
- mon.write(vol[2])
- mon.setBackgroundColor(colors.white)
- objloc.tape[2].speed.down = {(((x/2)-8)/2)+(x/2)-0.5,9}
- objloc.tape[2].speed.up = {objloc.tape[2].speed.down[1] + 7,9}
- mon.setPaletteColor(colors.yellow,0x7289DA)
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.white)
- mon.setCursorPos(objloc.tape[2].speed.down[1],9)
- mon.write("\171 \187")
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.black)
- mon.setCursorPos((((x/2)-6)/2+(x/2)),9)
- mon.write(" ")
- if #tostring(speed[2]) % 2 == 1 then
- mon.setCursorPos((((x/2)-#tostring(speed[2]))/2-1)+(x/2),9)
- else
- mon.setCursorPos((((x/2)-#tostring(speed[2]))/2)+(x/2),9)
- end
- mon.write(speed[2])
- mon.setBackgroundColor(colors.white)
- objloc.tape[3].volume.down = {((x/2)-8)/2-0.5,14}
- objloc.tape[3].volume.up = {objloc.tape[3].volume.down[1] + 7,14}
- mon.setPaletteColor(colors.yellow,0x7289DA)
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.white)
- mon.setCursorPos(objloc.tape[3].volume.down[1],14)
- mon.write("\171 \187")
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.black)
- mon.setCursorPos(((x/2)-6)/2,14)
- mon.write(" ")
- if #tostring(vol[3]) % 2 == 1 then
- mon.setCursorPos(((x/2)-#tostring(vol[3]))/2-1,14)
- else
- mon.setCursorPos(((x/2)-#tostring(vol[3]))/2,14)
- end
- mon.write(vol[3])
- mon.setBackgroundColor(colors.white)
- objloc.tape[3].speed.down = {((x/2)-8)/2-0.5,16}
- objloc.tape[3].speed.up = {objloc.tape[3].speed.down[1] + 7,16}
- mon.setPaletteColor(colors.yellow,0x7289DA)
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.white)
- mon.setCursorPos(objloc.tape[3].speed.down[1],16)
- mon.write("\171 \187")
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.black)
- mon.setCursorPos(((x/2)-6)/2,16)
- mon.write(" ")
- if #tostring(speed[3]) % 2 == 1 then
- mon.setCursorPos(((x/2)-#tostring(speed[3]))/2-1,16)
- else
- mon.setCursorPos(((x/2)-#tostring(speed[3]))/2,16)
- end
- mon.write(speed[3])
- mon.setBackgroundColor(colors.white)
- objloc.tape[4].volume.down = {(((x/2)-8)/2)+(x/2)-0.5,14}
- objloc.tape[4].volume.up = {objloc.tape[4].volume.down[1] + 7,14}
- mon.setPaletteColor(colors.yellow,0x7289DA)
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.white)
- mon.setCursorPos(objloc.tape[4].volume.down[1],14)
- mon.write("\171 \187")
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.black)
- mon.setCursorPos((((x/2)-6)/2)+(x/2),14)
- mon.write(" ")
- if #tostring(vol[4]) % 2 == 1 then
- mon.setCursorPos((((x/2)-#tostring(vol[4]))/2-1)+(x/2),14)
- else
- mon.setCursorPos((((x/2)-#tostring(vol[4]))/2)+(x/2),14)
- end
- mon.write(vol[4])
- mon.setBackgroundColor(colors.white)
- objloc.tape[4].speed.down = {(((x/2)-8)/2)+(x/2)-0.5,16}
- objloc.tape[4].speed.up = {objloc.tape[4].speed.down[1] + 7,16}
- mon.setPaletteColor(colors.yellow,0x7289DA)
- mon.setBackgroundColor(colors.yellow)
- mon.setTextColor(colors.white)
- mon.setCursorPos(objloc.tape[4].speed.down[1],16)
- mon.write("\171 \187")
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.black)
- mon.setCursorPos((((x/2)-6)/2+(x/2)),16)
- mon.write(" ")
- if #tostring(speed[4]) % 2 == 1 then
- mon.setCursorPos((((x/2)-#tostring(speed[4]))/2-1)+(x/2),16)
- else
- mon.setCursorPos((((x/2)-#tostring(speed[4]))/2)+(x/2),16)
- end
- mon.write(speed[4])
- return objloc
- end
- local currentVolume = {0.5,0.5,0.5,0.5}
- local lampStatus = 0
- local currentSpeed = {1,1,1,1}
- function mainThread()
- while true do
- if floor.getSize() then lampConnected = 1 else lampConnected = 0 end
- tape0.setVolume(currentVolume[1])
- tape1.setVolume(currentVolume[2])
- tape2.setVolume(currentVolume[3])
- tape3.setVolume(currentVolume[4])
- tape0.setSpeed(currentSpeed[1])
- tape1.setSpeed(currentSpeed[2])
- tape2.setSpeed(currentSpeed[3])
- tape3.setSpeed(currentSpeed[4])
- local objs = redraw(currentVolume,currentSpeed,lampStatus)
- local tEvent = {os.pullEvent("monitor_touch")}
- local x = tEvent[3]
- local y = tEvent[4]
- if tEvent[2] == "top" then
- for i=1,4 do
- if objs.tape[i].volume.down[1] < x+2 and objs.tape[i].volume.down[1] > x-2 then
- if objs.tape[i].volume.down[2] == y then
- if currentVolume[i] > 0.10 then
- currentVolume[i] = currentVolume[i] - 0.05
- currentVolume[i] = round(currentVolume[i],2)
- else currentVolume[i] = 0 end
- end
- end
- end
- for i=1,4 do
- if objs.tape[i].volume.up[1] < x+2 and objs.tape[i].volume.up[1] > x-2 then
- if objs.tape[i].volume.up[2] == y then
- if currentVolume[i] < 0.901 then
- currentVolume[i] = currentVolume[i] + 0.05
- currentVolume[i] = round(currentVolume[i],2)
- else currentVolume[i] = 1 end
- end
- end
- end
- for i=1,4 do
- if objs.tape[i].speed.down[1] < x+2 and objs.tape[i].speed.down[1] > x-2 then
- if objs.tape[i].speed.down[2] == y then
- if currentSpeed[i] > 0.30 then
- currentSpeed[i] = currentSpeed[i] - 0.05
- currentSpeed[i] = round(currentSpeed[i],2)
- else currentSpeed[i] = 0.25 end
- end
- end
- end
- for i=1,4 do
- if objs.tape[i].speed.up[1] < x+2 and objs.tape[i].speed.up[1] > x-2 then
- if objs.tape[i].speed.up[2] == y then
- if currentSpeed[i] < 1.90 then
- currentSpeed[i] = currentSpeed[i] + 0.05
- currentSpeed[i] = round(currentSpeed[i],2)
- else currentSpeed[i] = 2 end
- end
- end
- end
- if y == 18 then
- if lampStatus == 0 then lampStatus = 2 elseif lampStatus == 1 then lampStatus = 0 else lampStatus = 1 end
- end
- print("Checking rewind")
- print(x .. " " .. y)
- if x > 2 and x < 6 and y == 4 then rewind(1) end
- if x > 26 and x < 30 and y == 4 then rewind(2) end
- if x > 2 and x < 6 and y == 11 then rewind(3) end
- if x > 26 and x < 30 and y == 11 then rewind(4) end
- if x > 2 and x < 6 and y == 5 then pause(1) end
- if x > 26 and x < 30 and y == 5 then pause(2) end
- if x > 2 and x < 6 and y == 12 then pause(3) end
- if x > 26 and x < 30 and y == 12 then pause(4) end
- if x > 2 and x < 6 and y == 6 then play(1) end
- if x > 26 and x < 30 and y == 6 then play(2) end
- if x > 2 and x < 6 and y == 13 then play(3) end
- if x > 26 and x < 30 and y == 13 then play(4) end
- end
- end
- end
- function lampThread()
- local keklol = math.random(1,20)
- floor.setTextScale(5)
- local lamps = {peripheral.find("colorful_lamp")}
- while true do
- if lampStatus == 2 and floor.getSize() then
- local w,h = floor.getSize()
- for i=1,math.random((w*h)-(w*h/2),w*h) do
- floor.setCursorPos(math.random(1,w),math.random(1,h))
- floor.setBackgroundColor(2^math.random(0,15))
- floor.write(" ")
- end
- for i=0,15 do
- floor.setPaletteColor(2^i,colors.rgb8(math.random(80,255),math.random(80,255),math.random(80,255)))
- end
- end
- if lampStatus == 0 and floor.getSize() then
- floor.setPaletteColor(colors.black,0x000000)
- floor.setBackgroundColor(colors.black)
- floor.clear()
- end
- sleep(0.5)
- end
- end
- while true do
- parallel.waitForAny(function() err["mt"] = {pcall(mainThread)} end, function() err["lt"] = {pcall(lampThread)} end)
- print(textutils.serialise(err))
- print(pcall(errorReport))
- err = {}
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement