Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------(Setup)
- mon = peripheral.wrap("Top")
- ---colors
- bg=colors.black --background
- bo=colors.lightBlue --boarders
- txt=colors.blue --default text
- ----------------------------------(Functions)
- ------------------------[Passive]
- --------------{Clear}
- function mClear(bg1)
- mon.setBackgroundColor(bg1) --to change clear background color
- mon.clear()
- end
- --------------{Boarder}
- function mBoarder(bg2,txt2)
- for i=1,51 do
- mon.setTextColor(txt2)
- mon.setBackgroundColor(bg2) --to change boarder color
- mon.setCursorPos(i,1)
- mon.write("-")
- mon.setCursorPos(i,6)
- mon.write("-")
- mon.setCursorPos(i,19)
- mon.write("-")
- if i<20 then
- mon.setCursorPos(1,i)
- mon.write("|")
- mon.setCursorPos(25,i+5)
- mon.write("||")
- mon.setCursorPos(50,i)
- mon.write("|")
- end
- end
- end
- --------------{Header}
- --Coming Soon
- --------------{fields}
- function mfields(bg3,txt3)
- F={"Rubber Farm ","Steel Generator","Mob Grinder ","Laser Drills ","UU Generator ","Lag Limiter","Base Entrances","Empty Field 8","Empty Field 9","Empty Field 10"} --15 chars each
- j=2
- f=6
- for i=1,8 do
- if i<6 then j=2 f=6 else j=27 f=-4 end
- mon.setBackgroundColor(bg3) --to change background color
- mon.setTextColor(txt3)
- mon.setCursorPos(j,i*2+f)
- mon.write(" ")
- mon.write(F[i])
- end
- end
- --------------{fields status}
- function mStatus(bg4)
- B1=redstone.getBundledInput("bottom")
- for i=1,8 do
- if i<6 then j=2 f=6 else j=27 f=-4 end
- mon.setCursorPos(j+18,i*2+f)
- bool1 = bit32.extract(B1,i+7)
- if bool1==1 then
- mon.setBackgroundColor(colors.green) --to change background color
- mon.setTextColor(bg4)
- mon.write("ON ")
- else
- mon.setBackgroundColor(colors.red) --to change background color
- mon.setTextColor(bg4)
- mon.write("OFF")
- end
- end
- end
- ------------------------[Active]
- --------------{touchPos}
- function touchPos() --returns 0-7
- local Y=0
- local X=0
- --A,side,X,Y = os.pullEvent("monitor_touch")
- local eventtocatch = 'monitor_touch' --(for example)
- local timeout = os.startTimer(2)
- local A,side,X1,Y1 = os.pullEvent()
- write(A)
- print(side)
- if A=='timer' and side==timeout then
- Y=0
- X=0
- elseif A==eventtocatch then
- X=X1
- Y=Y1
- end
- --temp
- write("(")
- write(X)
- write(",")
- write(Y)
- write(")")
- if (X <= 22 and X >= 20 and Y == 8) then return(0)
- elseif (X <= 22 and X >= 20 and Y == 10) then return(1)
- elseif (X <= 22 and X >= 20 and Y == 12) then return(2)
- elseif (X <= 22 and X >= 20 and Y == 14) then return(3)
- elseif (X <= 22 and X >= 20 and Y == 16) then return(4)
- elseif (X <= 47 and X >= 45 and Y == 8) then return(5)
- elseif (X <= 47 and X >= 45 and Y == 10) then return(6)
- elseif (X <= 47 and X >= 45 and Y == 12) then return(7)
- else return(-1)
- end
- end
- ---------------{toggle}
- function toggle(pos)
- if pos >=0 then
- redstone.setBundledOutput("bottom",2^pos)
- os.sleep(0.05)
- redstone.setBundledOutput("bottom",0)
- end
- end
- ---------------------------------(Main Loop)
- while true do
- mClear(bg)
- mBoarder(bo,txt)
- mfields(bg,txt)
- mStatus(bg)
- pos=touchPos()
- write(pos) --temp
- toggle(pos)
- os.sleep(0.15)
- mStatus(bg)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement