Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function startup()
- rednet.open("top")
- file = fs.open("printerStatus","r")
- printerStatus = file.readLine()
- file.close()
- file = fs.open("actionCount","r")
- actionCount = file.readLine()
- file.close()
- rednet.send(928,{["action"]="sendingInfo",["infoType"]="printerStatus",["info"]=printerStatus})
- rednet.send(928,{["action"]="sendingInfo",["infoType"]="actionCount",["info"]=actionCount})
- if printerStatus ~= "moving" and printerStatus ~= "stopped" and (not fs.exists("stop")) then
- multishell.launch({},"printerController")
- end
- end
- function main()
- while true do
- info1,info2,info3,info4 = os.pullEvent()
- if info1 == "rednet_message" and info2 == 928 then
- if info3 == "heartbeat" then
- rednet.send(928,"heartbeat")
- file = fs.open("printerStatus","r")
- printerStatus = file.readLine()
- file.close()
- file = fs.open("actionCount","r")
- actionCount = file.readLine()
- file.close()
- rednet.send(928,{["action"]="sendingInfo",["infoType"]="printerStatus",["info"]=printerStatus})
- rednet.send(928,{["action"]="sendingInfo",["infoType"]="actionCount",["info"]=actionCount})
- end
- if info3 == "stop" then
- file = fs.open("stop","w")
- file.flush()
- file.close()
- end
- if info3 == "start" and (printerStatus == "stopped" or printerStatus == "standby") then
- if fs.exists("stop") then
- fs.delete("stop")
- end
- multishell.launch({},"printerController")
- end
- if type(info3) == "number" then
- file = fs.open("actionCount","w")
- file.write(info3)
- file.flush()
- file.close()
- end
- if info3 == "clear" then
- shell.run("clear")
- end
- if info3 == "turtleTurn" then
- shell.run("turtleTurn")
- end
- if info3 == "turtleForward" then
- shell.run("turtleForward")
- end
- if info3 == "turtleUp" then
- shell.run("turtleUp")
- end
- if info3 == "machineForward" then
- multishell.launch({},"machineForward")
- end
- if info3 == "refuel" then
- multishell.launch({},"turtleRefuel")
- end
- if info3 == "print" then
- multishell.launch({},"printer")
- end
- end
- end
- end
- startup()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement