Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- MAINFRAME PROGRAM
- ]]--
- local function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- --[[
- EVENTS AND THEIR PARAMETERS.
- redstone: Returns NO parameters.
- modem_message:
- * param1: string side
- * param2: number frequency
- * param3: number replyFrequency
- * param4: message
- * param5: number distance travelled
- - a good way to detect from where the modem message came from is by checking the replyFrequency.
- rednet_message:
- * param1: number senderID
- * param2: message
- * param3: protocol/message travelled
- USEFUL KEYPRESS CHEAT SHEET:
- * arrow up: 200
- * arrow down: 208
- * arrow left: 203
- * arrow right: 205
- * E: 18
- * Enter: 28
- * Space: 57
- ERROR DEBUGGING:
- * Check if event params are in quotation marks. example: if event == "key" then
- ]]
- local remotecomp1name = "computer_2"
- local monitor = peripheral.wrap("monitor_1")
- local modem = peripheral.wrap("bottom")
- modem.open(1)
- clear()
- print(" * Mainframe")
- print(" [E] to exit.")
- print(" Modem opened on frequency 1")
- term.setCursorPos(1,6)
- print(" [1] Farmhouse sensor update")
- while true do
- local event, param1, param2, param3, param4, param5 = os.pullEvent()
- -- exit from the program
- if event == "key" and param1 == 18 then
- clear()
- sleep(0.1)
- break
- elseif event == "key" and param1 == 2 then
- local remotecomp = peripheral.wrap(remotecomp1name)
- remotecomp.turnOn()
- elseif event == "redstone" then
- if redstone.testBundledInput("back",1) == true then
- local remotecomp = peripheral.wrap(remotecomp1name)
- remotecomp.turnOn()
- end
- elseif event == "modem_message" and param3 == 2 then
- local time = os.time()
- local ttime = textutils.formatTime(time,true)
- local rmsg = textutils.unserialize(param4)
- print(rmsg[1])
- print(rmsg[2])
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write("Day: "..os.day().." at "..ttime)
- monitor.setCursorPos(1,3)
- monitor.write(rmsg[1].." ["..rmsg[2].."] is in the farmhouse.")
- monitor.setCursorPos(1,4)
- monitor.write("Press T to activate teslas.")
- redstone.setBundledOutput("back",16)
- sleep(0.1)
- redstone.setBundledOutput("back",0)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement