Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rsmax=14
- rsmin=4
- local mon = peripheral.wrap("top")
- local monScale = 0.5
- mon.setTextScale(monScale)
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(2,1)
- mon.write("Engine 1 (Left):")
- mon.setCursorPos(2,6)
- mon.write("Engine 2 (Right):")
- local w,h = mon.getSize()
- w = math.floor(w / 2)
- print(w," ",h)
- local col3 = {colors.red, colors.yellow, colors.green}
- local col5 = {colors.red, colors.orange, colors.yellow, colors.lime, colors.green}
- local col, ncol, n
- if w % 3 < w % 5 then
- col = col3
- ncol = 3
- w = w - (w % 3)
- else
- col = col5
- ncol = 5
- w = w - (w % 5)
- end
- n = w / ncol
- wNew1 = w
- wNew2 = w
- local start = true
- lefton=false
- righton=false
- while true do
- print(redstone.getAnalogInput("left").."/"..redstone.getAnalogInput("right"))
- wOld1 = wNew1
- eNow1 = redstone.getAnalogInput("left")
- eMax1 = 14
- wNew1 = math.ceil(w * eNow1 / eMax1)
- if wOld1 ~= wNew1 or start then
- mon.setBackgroundColor(colors.black)
- for j = 2,5 do
- for i=1,w*2 do
- mon.setCursorPos(i,j)
- mon.write(" ")
- end
- end
- for i = 1,wNew1 do
- for j = 2,5 do
- mon.setCursorPos(i*2 - 1,j)
- mon.setBackgroundColor(col[math.ceil(i/n)])
- mon.write(" ")
- mon.setCursorPos(i*2,j)
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- end
- end
- end
- wOld2 = wNew2
- eNow2 = redstone.getAnalogInput("right")
- eMax2 = 14
- wNew2 = math.ceil(w * eNow2 / eMax2)
- if wOld2 ~= wNew2 or start then
- mon.setBackgroundColor(colors.black)
- for j = 7,10 do
- for i=1,w*2 do
- mon.setCursorPos(i,j)
- mon.write(" ")
- end
- end
- for i = 1,wNew2 do
- for j = 7,10 do
- mon.setCursorPos(i*2 - 1,j)
- mon.setBackgroundColor(col[math.ceil(i/n)])
- mon.write(" ")
- mon.setCursorPos(i*2,j)
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- end
- end
- end
- start = false
- if redstone.getAnalogInput("right") >= rsmax then
- if lefton then
- redstone.setBundledOutput("bottom",3)
- else
- redstone.setBundledOutput("bottom",1)
- end
- righton=true
- elseif redstone.getAnalogInput("right") <= rsmin then
- if lefton then
- redstone.setBundledOutput("bottom",2)
- else
- redstone.setBundledOutput("bottom",0)
- end
- righton=false
- end
- if redstone.getAnalogInput("left") >= rsmax then
- if righton then
- redstone.setBundledOutput("bottom",3)
- else
- redstone.setBundledOutput("bottom",2)
- end
- lefton =true
- elseif redstone.getAnalogInput("left") <= rsmin then
- if righton then
- redstone.setBundledOutput("bottom",1)
- else
- redstone.setBundledOutput("bottom",0)
- end
- lefton=false
- end
- sleep(5)
- end
Add Comment
Please, Sign In to add comment