This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Tech0verlord's profile picture

Hidden Admin Chat (feedback appreciated)

Started by Tech0verlord, 29 May 2013 - 12:44 PM
Tech0verlord #1
Posted 29 May 2013 - 02:44 PM
This is a neat little program I made that can be used by admins on a server to communicate at the spawn point (or anywhere else in the world) anonymously. This was designed with the computer being attached to a monitor via wired modems and cables. When testing I used a 3x3 monitor. If you want to hook up another monitor (so that you can see what is being output, or for multiple locations), just uncomment the lines beginning with –monitor2. I suggest you keep the cables underground and hopefully keep the ground and the cables protected (world guard or some other mod maybe?). Please tell me what you think!

Wired Version
Spoiler

monitor = peripheral.wrap("monitor_0")
--monitor2 = peripheral.wrap("monitor_1")
clear = "***"
exit = "-99-"
function newLine() --Thanks Pinkishu
  local _,cY= monitor.getCursorPos()
  monitor.setCursorPos(1,cY+1)
  --monitor2.setCursorPos(1,cY+1)
end
while true do
  term.clear()
  term.setCursorPos(1, 1)
  write("Say:")
  local input = read()
  monitor.write(input)
  --monitor2.write(input)
  newLine()
  if input == clear then
	monitor.clear()
	monitor.setCursorPos(1, 1)
	--monitor2.clear()
	--monitor2.setCursorPos(1, 1)
  end
  if input == exit then
	monitor.clear()
	monitor.setCursorPos(1, 1)
	--monitor2.clear()
	--monitor2.setCursorPos(1, 1)
	term.clear()
	term.setCursorPos(1, 1)
	print("Exiting Chat...")
	sleep(2)
	term.clear()
	term.setCursorPos(1, 1)
	return
  end
end

If I am not mistaken, then this code will let you download it in game.

pastebin get uviEFzR2

Wireless/RedNet Version(WIP)
SpoilerSending Computer(Done!)
Spoiler

----Sender----
rednet.open("back")
receiverID = 22
password = "techoverlord"
clear = "***"
exit = "-99-"
--End of Variables--
function newLine()
  local _,cY = term.getCursorPos()
  term.setCursorPos(1, cY+1)
end
  term.clear()
  term.setCursorPos(1, 1)
  term.write("Password:")
  local input = read("*")
  if input == password then
	term.write("ACCESS GRANTED")
	sleep(1)
	while true do
	  term.clear()
	  term.setCursorPos(1, 1)
	  term.write("Say:")
	  local input = read()
	  rednet.send(receiverID, input)
	  if input == clear then
		term.clear()
		term.setCursorPos(1, 1)
		rednet.send(receiverID, input)
	  end
	  if input == exit then
		term.clear()
		term.setCursorPos(1, 1)
		term.write("Exiting chat...")
		sleep(2)
		os.shutdown()
	  end
	end
  end
  if input ~= password then
	term.write("ACEESS DENIED")
	sleep(2)
	os.reboot()
  end

Receiving Computer (Almost Done - Annoying bug needs squashing)
Spoiler

----Receiver----
rednet.open("back")
monitor = peripheral.wrap("right")
clear = "***"
exit = "-99-"
senderID = 23
id, message = rednet.receive()
--End of Variables--
function newLine()
  local _,cY = monitor.getCursorPos()
  monitor.setCursorPos(1, cY+1)
end
while true do
  term.clear()
  term.setCursorPos()
  if id == senderID then
	monitor.write(message)
	newLine()
	if message == clear then
	  monitor.clear()
	  monitor.setCursorPos(1, 1)
	end
	if message == exit then
	  monitor.clear()
	  monitor.setCursorPos(1, 1)
	  os.reboot()
	end
  end
  if id ~= senderID then
	rednet.send(id, "YOU DO NOT HAVE ACCESS TO THIS COMPUTER")
  end
end
bjornir90 #2
Posted 30 May 2013 - 12:14 PM
Edit : forget that I was wrong ….
Zudo #3
Posted 30 May 2013 - 12:16 PM
bjornir is right, but this is good for a 1st post!

EDIT: No, the code is fine.
Cranium #4
Posted 30 May 2013 - 12:30 PM
This will not work as read() output a string so you need to do :
if input == "clear" then
He is referring to the variables clear and exit that are stated at the top of the code. His code is functioning correctly.
bjornir90 #5
Posted 30 May 2013 - 04:39 PM
Oh ok sorry didn't notice that ….
Tech0verlord #6
Posted 30 May 2013 - 06:01 PM
Thanks guys. I find using computer craft very fun, and I actually have no coding experience whatsoever, so what is posted is from what I learned from the wiki and expanding on the door lock tutorial on there. The variables are there for ease of keyword customization and monitor name changing.

EDIT: I updated the first post with the code to get the program from in-game

EDIT2: Sorry for the double post, but I would just let you know that I am currently working on expanding this program to create a RedNet enabled version. I may need some help along the way so I will be periodically posting information about the current coding. At the moment, I'm working on the coding for the receiving computer that will output to the monitor.

EDIT3: OMG TRIPPLE POST SORRY GUYS!!!

Oddly enough, I finished the sender's code first. I rewrote the receiver's code, but unfortunately, it has a bug where it repeats the same message over and over on the monitor until the program errors out. It also repeats the clear and exit command, while executing them at the same time. Anyone know of a way to fix it? It has to loop though so that the computer can keep receiving messages, but not repeat them on the monitor till it errors out.

I've updated the first post with the current code.
Tech0verlord #7
Posted 31 May 2013 - 12:20 PM
<DELETE THIS POST>
Tech0verlord #8
Posted 01 June 2013 - 01:45 AM
<DELETE THIS POST>
jesusthekiller #9
Posted 01 June 2013 - 07:05 AM
OMG TRIPPLE POST SORRY GUYS!!!

bjornir90 #10
Posted 01 June 2013 - 07:27 AM
I sent you a pm if you need help with rednet or gui :)/>