Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --OAK 105
- --SPRUCE 104
- mouseWidth = 0
- mouseHeight = 0
- rednet.open("bottom")
- monitor = peripheral.wrap("back")
- monitor.clear()
- monitor.setCursorPos(1,1)
- w,h=monitor.getSize()
- print(w)
- print(h)
- requestG = {"JungleG", "AcaciaG", "RubberG", "BirchG"}
- i=1
- bt1=false
- bt2=false
- bt3=false
- bt4=false
- can=false
- connected=false
- monitor.setBackgroundColour(colors.black)
- function write(linex, liney, color, text)
- monitor.setCursorPos(linex,liney)
- monitor.clearLine()
- monitor.setTextColor(color)
- monitor.write(text)
- monitor.setTextColor(colors.white)
- end
- function request(id, message)
- rednet.send(id, message)
- end
- function Connected()
- monitor.clear()
- write(1, 1, colors.orange, "Connecting to DataServer:81...")
- request(81, "isAlive")
- id, message = rednet.receive(5)
- if(id==81) then
- if(message=="yes") then
- connected=true
- sleep(1)
- write(1, 2, colors.lime, "Connected !")
- sleep(1)
- write(1, 3, colors.orange, "Starting CraftNet:W_CONTROL..")
- sleep(5)
- getbtn()
- end
- end
- if(connected==false) then
- sleep(1)
- write(1, 2, colors.red, "Error try again in 5seconds!")
- sleep(5)
- Connected()
- end
- end
- function getbtn()
- request(81, requestG[i])
- id, message = rednet.receive(5)
- if(id==81) then
- if(message=="true") then
- can=false
- if(i==1) then
- bt1ac()
- elseif(i==2) then
- bt2ac()
- elseif(i==3) then
- bt3ac()
- elseif(i==4) then
- bt4ac()
- end
- else
- can=false
- if(i==1) then
- bt1inac()
- elseif(i==2) then
- bt2inac()
- elseif(i==3) then
- bt3inac()
- elseif(i==4) then
- bt4inac()
- end
- end
- end
- if(i==4) then
- print(can)
- print(i)
- end
- if(i <= 4) then
- i=i+1
- getbtn()
- end
- end -- end function getbtn
- local function addcol(col, side)
- rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side),col))
- end
- local function remcol(col, side)
- rs.setBundledOutput(side, colors.subtract(rs.getBundledOutput(side),col))
- end
- function bt1inac()
- monitor.setBackgroundColour((colours.red))
- write(1, 1, colors.white, "INACTIVE : Jungle Wood")
- remcol(colors.white, "right")
- if(can==true) then
- request(81, "Jungle")
- end
- bt1=false
- can=true
- monitor.setBackgroundColour(colors.black)
- --text
- end
- function bt1ac()
- monitor.setBackgroundColour(colors.lime)
- write(1, 1, colors.white, "ACTIVE : Jungle Wood")
- addcol(colors.white, "right")
- if(can==true) then
- request(81, "Jungle")
- end
- bt1=true
- can=true
- monitor.setBackgroundColour(colors.black)
- end
- function bt2inac()
- monitor.setBackgroundColour(colors.red)
- remcol(colors.yellow, "right")
- write(1, 2, colors.white, "INACTIVE : Acacia Wood")
- monitor.setBackgroundColour(colors.black)
- if(can==true) then
- request(81, "Acacia")
- end
- bt2=false
- can=true
- end
- function bt2ac()
- monitor.setBackgroundColour(colors.lime)
- addcol(colors.yellow, "right")
- write(1, 2, colors.white, "ACTIVE : Acacia Wood")
- monitor.setBackgroundColour(colors.black)
- if(can==true) then
- request(81, "Acacia")
- end
- bt2=true
- can=true
- end
- function bt3inac()
- monitor.setBackgroundColour(colors.red)
- remcol(colors.lime, "right")
- write(1, 3, colors.white, "INACTIVE : Rubber Wood")
- monitor.setBackgroundColour(colors.black)
- if(can==true) then
- request(81, "Rubber")
- end
- bt3=false
- can=true
- end
- function bt3ac()
- monitor.setBackgroundColour(colors.lime)
- addcol(colors.lime, "right")
- write(1, 3, colors.white, "ACTIVE : Rubber Wood")
- monitor.setBackgroundColour(colors.black)
- if(can==true) then
- request(81, "Rubber")
- end
- bt3=true
- can=true
- end
- function bt4inac()
- monitor.setBackgroundColour(colors.red)
- remcol(colors.pink, "right")
- write(1, 4, colors.white, "INACTIVE : Birch Wood")
- monitor.setBackgroundColour(colors.black)
- if(can==true) then
- request(81, "Birch")
- end
- bt4=false
- can=true
- end
- function bt4ac()
- monitor.setBackgroundColour(colors.lime)
- addcol(colors.pink, "right")
- write(1, 4, colors.white, "ACTIVE : Birch Wood")
- monitor.setBackgroundColour(colors.black)
- if(can==true) then
- request(81, "Birch")
- end
- bt4=true
- can=true
- end
- monitor.setBackgroundColour((colours.black))
- --background screen color
- --START
- Connected()
- function checkClickPosition()
- print(can)
- if mouseWidth > 0 and mouseWidth < 30 and mouseHeight == 1 then
- -- button one clicked
- if(bt1==false) then
- bt1=true
- addcol(colors.white, "right")
- bt1ac()
- else
- bt1=false
- remcol(colors.white, "right")
- bt1inac()
- end
- elseif mouseWidth > 0 and mouseWidth <30 and mouseHeight == 2 then
- if(bt2==false)then
- bt2=true
- addcol(colors.yellow, "right")
- bt2ac()
- else
- bt2=false
- remcol(colors.yellow, "right")
- bt2inac()
- end
- elseif mouseWidth > 0 and mouseWidth <30 and mouseHeight == 3 then
- if(bt3==false)then
- bt3=true
- addcol(colors.lime, "right")
- bt3ac()
- else
- bt3=false
- remcol(colors.lime, "right")
- bt3inac()
- end
- elseif mouseWidth > 0 and mouseWidth <30 and mouseHeight == 4 then
- if(bt4==false)then
- bt4=true
- addcol(colors.pink, "right")
- bt4ac()
- else
- bt4=false
- remcol(colors.pink, "right")
- bt4inac()
- end
- end -- ends the if loop
- end -- ends the function
- repeat
- event,p1,p2,p3 = os.pullEvent()
- if event=="monitor_touch" then
- mouseWidth = p2 -- sets mouseWidth
- mouseHeight = p3 -- and mouseHeight
- checkClickPosition() -- this runs our function
- end
- until event=="char" and p1==("x")
Advertisement
Add Comment
Please, Sign In to add comment