Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Basic RSRPrint - by Mikk809h
- -- Redstone Signal Receive Print --
- -- mode
- local mode = 1
- -- 1 = redstone signal. 2 = rednet signal. 3 = key signal.
- -- Variables --
- local AcceptMsg = false
- local AcceptkeyMsg = false
- -- if mode is 1 then only edit this.
- local moreSides = {"top", "bottom", "right", "left", "front", "back"};
- -- input side. delete the sides that you dont want to use.
- local message = "No signal"; -- if no signal received.
- local message2 = "Signal Received"; -- if signal received.
- -- if mode is 2 then only edit this.
- local modemSide = {"top"};
- -- leave, if all sides has a modem. (xD)
- -- Turn Signal On When Message Is Received
- local messageToReceive = "Hello";
- -- edit the "" to the message you want. like:
- -- if you want it to turn the signal to true, when receiving the message "Hello" then
- -- change(messageToReceive) = "Hello"
- local message3 = "No signal received";
- local message4 = "Signal received";
- -- if mode is 3 then only edit this.
- local chars = {keys.enter, keys.tab, keys.space, keys.backspace} -- add keys.key (key is the name of the letter/key.)
- -- Signal is received when one of thoose chars is pressed/used.
- local message5 = "No signal received";
- local message6 = "Signal received";
- local messageRec = "Key: " -- a little hotbar at bottom of screen which shows which key is pressed.
- --
- -- Main
- --
- -- If you want to return back to shell when done edit this to true.
- local stopWhenReceivingSignal = true
- -- clear screen
- term.clear();
- term.setCursorPos(1,1) ;
- -- loop/main
- while true do -- loops the checker + the printed text.
- if mode == 1 then
- for k,v in pairs(moreSides) do -- checks all sides in the "moreSides" table.
- if rs.getInput(v) ~= true then -- if the side does not equals to true, then ...
- term.setCursorPos(1,1) ;
- term.clearLine() ;
- term.write(message) ; -- prints the message you want, when it does NOT receive a signal.
- else
- term.setCursorPos(1,1) ;
- term.clearLine() ;
- term.write(message2) ; -- prints the message you want, when it receives a signal.
- AcceptMsg = true
- if stopWhenReceivingSignal then -- if you want it to return back to shell after it receives a signal.
- return false -- breaks the loop and returns to shell.
- end
- end
- end
- elseif mode == 2 then -- if the mods is for rednet then...
- for k,v in pairs(modemSide) do -- checks all sides in the "modemSide" table.
- if v then
- rednet.open(v) ; -- opens the sides you have declaired in the modemSide table.
- end
- end
- if AcceptMsg == false then
- term.setCursorPos(1,1) ;
- term.clearLine() ;
- term.write(message3) ;
- end
- local event, id, msg = os.pullEvent("rednet_message") -- make a pull event.
- if event == "rednet_message" then
- if msg == messageToReceive then -- if it receives the message.
- term.setCursorPos(1,1) ;
- term.clearLine() ;
- term.write(message4) ; -- prints the message you want, when it does receive a signal.
- sleep(4)
- AcceptMsg = true
- if stopWhenReceivingSignal then -- if you want it to return back to shell after it receives a signal.
- return false -- breaks the loop and returns to shell.
- end
- else
- term.setCursorPos(1,1) ;
- term.clearLine() ;
- term.write(message3) ; -- prints the message you want, when it does not receive a signal.
- end
- else
- term.setCursorPos(1,1) ;
- term.write(message3) ;
- end
- elseif mode == 3 then -- if mode is the key event.
- if AcceptkeyMsg == false then
- term.setCursorPos(1,1) ;
- term.clearLine() ;
- term.write(message5) ;
- end
- local event, key = os.pullEvent("key")
- term.setCursorPos(1,19)
- term.clearLine()
- term.write(messageRec)
- term.write(key)
- if event == "key" then
- for k,v in pairs(chars) do
- if key == chars[k] then
- term.setCursorPos(1,1) ;
- term.clearLine() ;
- term.write(message6) ; -- prints the message you want, when it does receive a signal.
- AcceptkeyMsg = true
- if stopWhenReceivingSignal then -- if you want it to return back to shell after it receives a signal.
- return false -- breaks the loop and returns to shell.
- else
- sleep(1)
- AcceptkeyMsg = false
- end
- else
- term.setCursorPos(1,1) ;
- term.clearLine() ;
- term.write(message5) ; -- prints the message you want, when it does not receive a signal.
- end
- end
- else
- term.setCursorPos(1,1) ;
- term.clearLine() ;
- term.write(message5) ; -- prints the message you want, when it does not receive a signal.
- end
- else
- return false
- end
- sleep(0) ; -- sleeps 0 seconds so it wouldnt return "too long without yielding..."
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Thanks for using RedStoneKey Receive-Print!\n\n")
Advertisement
Add Comment
Please, Sign In to add comment