function getmodems(mode) mode = mode or "default" if mode == "default" then allp = peripheral.getNames() d = {} x = 0 for i,value in ipairs(allp) do c = peripheral.getType(value) if c == "modem" then c = peripheral.wrap(value) x = x + 1 d[x] = c end end d["a"] = x d["amount"] = x return d elseif mode == "sides" or mode =="s" then allp = peripheral.getNames() d = {} x = 0 for i,value in ipairs(allp) do c = peripheral.getType(value) if c == "modem" then x = x + 1 d[x] = value end end d["a"] = x d["amount"] = x return d end end function getmsg() while true do d = {} event, side, frequency, replyFrequency, message, distance = os.pullEvent("modem_message") d["e"] = event d["s"] = side d["f"] = frequency d["rf"] = replyFrequency d["m"] = message d["d"] = distance return d end end function transmitall(p,rp,message) modems = getmodems() print(modems["a"]) if modems["a"] == 0 then else for modem = 1,modems["a"] do cm = modems[modem] cm.transmit(p,rp,message) end end end function relay(p,rp,message,exclude) sides = getmodems("s") if modems["a"] == 0 then else for side = 1,modems["a"] do cs = sides[side] if cs == exclude then else cm.transmit(p,rp,message) end end end end function fill() paintutils.drawFilledBox(1, 1, 1000, 1000, colors.gray) end function cooldown (time) for i = 1,time do term.clear() term.setCursorPos(5,3) print(time-i+1) sleep(1) end return 0 end function createbutton(x,y,w,h,color,message) d = {} function d:init(x,y,w,h,color,message) self.x1 = x self.x2 = x+w self.y1 = y self.y2 = y+h self.color = color self.message = message end function d:isclickon (x,y) if self.x1 <= x and x <= self.x2 and self.y1 <= y and y <= self.y2 then return true else return false end end function d:draw () --print(self.x1) paintutils.drawFilledBox(self.x1,self.y1,self.x2,self.y2,self.color) term.setTextColor(colors.white) term.setBackgroundColor(colors.black) end d:init(x,y,w,h,color,message) return d end function toggle() if farmon() then local h = fs.open("open.txt", "w") h.write("0") h.close() else local h = fs.open("open.txt", "w") h.write("1") h.close() end end function farmon() local h = fs.open("open.txt", "r") local a = tonumber(h.readLine()) --print("value in fle is: " .. tostring(a)) h.close() if a == 1 then return true else return false end end function farmona() local h = fs.open("running.txt", "r") local a = tonumber(h.readLine()) --print("value in fle is: " .. tostring(a)) h.close() return a end function togglea(newnumber) local h = fs.open("running.txt", "w") h.write(newnumber) h.close() end function drawtext(text,x,y) term.setCursorPos(x,y) term.setBackgroundColor(colors.black) print(text) end term.redirect(peripheral.wrap("left")) moni = peripheral.wrap("left") moni.setTextScale(2) but1 = createbutton(25,2,1,1,colors.green,"") but2 = createbutton(15,4,3,1,colors.green,"") but3 = createbutton(17,4,2,1,colors.red,"") but4 = createbutton(17,4,2,1,colors.yellow,"") but5 = createbutton(25,2,1,1,colors.yellow,"") local on = false local skip = false local first = true local waiting = false while true do local time = os.time() local formattedTime = textutils.formatTime(time, false) term.clear() fill() but1:draw() if farmon() then iso = "on" else iso = "off" end drawtext("Bone processing:",2,2) drawtext(iso,20,2) if not on then but2:draw() drawtext("Start farm:",2,4) if not first then if but2:isclickon(xPos,yPos) then togglea(1) xPos = 0 yPos = 0 on = true skip = true sleep(0.05) shell.run("bg pastebin run 9wqiNK6g") end end else paintutils.drawFilledBox(2,4,20,8) cn = farmona() if cn == 0 then on = false waiting = false elseif cn == 1 then waiting = false but3:draw() drawtext("Running",3,5) if but3:isclickon(xPos,yPos) then xPos = 0 yPos = 0 skip = true waiting = true togglea(2) end elseif cn == 2 then but5:draw() but4:draw() drawtext("Stopping.",3,5) sleep(0.5) drawtext("Stopping..",3,5) sleep(0.5) drawtext("Stopping...",3,5) sleep(0.5) end end --drawtext(formattedTime,14,5) if not skip then event, side, xPos, yPos = os.pullEvent("monitor_touch") if but1:isclickon(xPos,yPos) then toggle() xPos = 0 yPos = 0 end end if not waiting then skip = false end first = false --print(but1:isclickon(mx,my)) --print(but2:isclickon(mx,my)) end