View difference between Paste ID: 9qKsnuAh and PLQ6SqeC
SHOW: | | - or go back to the newest paste.
1
-- So, main diagnostic: The client isnt reading. I tried to implement parallel today, not working out, must sleep. Attempt to have the input and rednet receiving all at the same time, for that is just what the solution to this problem is.
2
3
function mainLoop()
4
print("Main loop activated")
5
	rednet.send(tonumber(hostid),"connect") 
6
print("SENT")
7
	id,msg,dist=rednet.receive() 
8-
  if id==hostid then inType=msg print("Input Type: "..inType) 
8+
  if id==hostid then inType=msg print("Input Type: "..inType) end -- Sends the connection notice to the server.
9-
end -- Sends the connection notice to the server.
9+
10
while true do -- Begin the loop.
11
12
 ev,p1,p2,p3=os.pullEvent("rednet_message")
13
14
   if ev=="rednet_message" and p1==hostid then print("["..p1.."]{"..p3.."}: "..p2) end -- Receiving.
15
   if ev=="rednet_message" and p1==hostid then if p2=="key" then inType="key" end end
16
   if ev=="rednet_message" and p1==hostid then if p2=="string" then inType="string" end end
17
   if ev=="rednet_message" and p1==hostid then if p2=="exit" then break; end end
18
19
if inType=="key" then -- KEY INPUT
20
	ev,p1,p2,p3=os.pullEvent("char") -- Pull any events. 
21
		if ev=="char" then
22
			if ev=="char" and p1=="e" then rednet.send(hostid,"disconnect") print("Exiting") error() 
23
			 end -- Exit key.
24
		print("Input: "..p1)
25
   		 data=tostring(p1) -- Tostringing the parameter 1.
26
		rednet.send(hostid,data) 
27
	data=nil
28
end
29
end
30
31
32
if inType=="string" then -- STRING INPUT
33
	data=read()
34
  rednet.send(hostid,data) 
35
end
36
37
 end
38
39
end
40
41
function intro()
42
  rednet.open("top") -- Open the top port.
43
  rednet.open("right")
44
  rednet.open("left")
45
  rednet.open("back")
46
  inType="string"
47
print("Host ID?")
48
 hostid=read() -- Fetch the host ID.
49-
 hostid=tonumber(read()) -- Fetch the host ID.
49+
50
end
51
52
  term.clear()
53
  term.setCursorPos(1,1)
54
intro()