Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Startup()
- if fs.exists("DrillData") then
- DataInit(true)
- if (DrillID == nil or DrillID == "") then
- Setup(true)
- else
- Drilling(true)
- end
- else
- Setup(true)
- end
- end
- function DataInit()
- file = fs.open("DrillData/".."Data", "r")
- DrillData = {}
- Data = file.readLine()
- repeat
- table.insert(DrillData, Data)
- Data = file.readLine()
- until Data == nil
- file.close()
- DrillID = DrillData[1]
- DrillName = DrillData[2]
- end
- function Setup()
- print("\nEnter this drill's ID\n")
- DrillID = read()
- fs.makeDir("DrillData")
- file = fs.open("DrillData/".."Data", "w")
- file.writeLine(DrillID)
- file.close()
- DataInit(true)
- loop(true)
- end
- function Drilling()
- id, message = rednet.receive("Drill"..DrillID)
- if message == "Drill"..DrillID.."Activation" then
- print("\nActivated Laser Drill")
- redstone.setOutput("bottom", true)
- os.sleep(1)
- loop(true)
- elseif message == "Drill"..DrillID.."Deactivation" then
- print("\nDeactivated Laser Drill")
- redstone.setOutput("bottom", false)
- os.sleep(1)
- loop(true)
- elseif message == "Status" then
- status = redstone.getOutput("bottom")
- if status == true then
- rednet.broadcast("On", "Drill"..DrillID)
- Drilling(true)
- elseif status == false then
- rednet.broadcast("Off", "Drill"..DrillID)
- loop(true)
- end
- else
- os.sleep(0.5)
- loop(true)
- end
- end
- function loop()
- os.sleep(0.5)
- Drilling(true)
- end
- rednet.open("top")
- Startup(true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement