Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local beeType = ""
- local alvearyNumber = 0
- local mode = "not running"
- if redstone.getOutput("back") then
- mode = "running"
- end
- rednet.open("bottom")
- function saveVar()
- local file = fs.open("beeSystemVariables","w")
- file.writeLine(beeType)
- file.writeLine(alvearyNumber)
- file.close()
- end
- function loadVar()
- if not fs.exists("beeSystemVariables") then setVar() return end
- local file = fs.open("beeSystemVariables","r")
- beeType = file.readLine()
- alvearyNumber = tonumber(file.readLine())
- file.close()
- end
- function setVar()
- clear()
- local input = ""
- while input == "" do
- print("Which type of bee is in the alveary?")
- print("Hit Enter to set the name!")
- input = read()
- end
- beeType = input
- input = 0
- while input <= 0 or input > 10 do
- clear()
- print("Enter a number between 1 and 10!")
- print("This is used to shutdown this alveary individually if you are having multiple " .. beeType .. " running in different alvearies.")
- input = tonumber(read())
- end
- alvearyNumber = input
- saveVar()
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function changeMode(newState)
- for k,v in pairs(redstone.getSides()) do
- redstone.setOutput(v, newState)
- end
- if redstone.getOutput("back") then
- mode = "running"
- else
- mode = "not running"
- end
- saveVar()
- end
- function run()
- clear()
- print("Bee Type: " .. beeType)
- print("Type Number: " .. alvearyNumber)
- term.write("This alveary is " .. mode)
- local event = { os.pullEvent() }
- if event[1] == "key" then
- setVar()
- elseif event[1] == "rednet_message" then
- local m = textutils.unserialize(event[3])
- if type(m[1]) == "string" and type(m[2]) == "string" and type(m[3]) == "number" then
- if m[2] == beeType and m[3] == alvearyNumber then
- if m[1] == "TurnOn" then
- changeMode(true)
- elseif m[1] == "TurnOff" then
- changeMode(false)
- end
- end
- end
- end
- end
- loadVar()
- while true do
- run()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement