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 HandleStuff() | |
4 | ||
5 | while true do -- Begin the loop. | |
6 | ||
7 | ev,p1,p2,p3=os.pullEvent("rednet_message") | |
8 | - | if id==hostid then inType=msg print("Input Type: "..inType) end -- Sends the connection notice to the server. |
8 | + | |
9 | if ev=="rednet_message" and p1==hostid then print("["..p1.."]{"..p3.."}: "..p2) end -- Receiving. | |
10 | if ev=="rednet_message" and p1==hostid then if p2=="key" then inType="key" end end | |
11 | if ev=="rednet_message" and p1==hostid then if p2=="string" then inType="string" end end | |
12 | if ev=="rednet_message" and p1==hostid then if p2=="exit" then break; end end | |
13 | ||
14 | if inType=="key" then -- KEY INPUT | |
15 | ev,p1,p2,p3=os.pullEvent("char") -- Pull any events. | |
16 | if ev=="char" then | |
17 | if ev=="char" and p1=="e" then rednet.send(hostid,"disconnect") print("Exiting") error() | |
18 | end -- Exit key. | |
19 | print("Input: "..p1) | |
20 | data=tostring(p1) -- Tostringing the parameter 1. | |
21 | rednet.send(hostid,data) | |
22 | data=nil | |
23 | end | |
24 | end | |
25 | ||
26 | ||
27 | if inType=="string" then -- STRING INPUT | |
28 | data=read() | |
29 | rednet.send(hostid,data) | |
30 | end | |
31 | ||
32 | end | |
33 | ||
34 | end | |
35 | ||
36 | function mainLoop() | |
37 | - | end |
37 | + | |
38 | rednet.send(tonumber(hostid),"connect") | |
39 | print("SENT") | |
40 | id,msg,dist=rednet.receive() | |
41 | if id==hostid then inType=msg print("Input Type: "..inType) end-- Sends the connection notice to the server. | |
42 | HandleStuff() | |
43 | end | |
44 | ||
45 | function intro() | |
46 | rednet.open("top") -- Open the top port. | |
47 | rednet.open("right") | |
48 | rednet.open("left") | |
49 | rednet.open("back") | |
50 | inType="string" | |
51 | print("Host ID?") | |
52 | hostid=read() -- Fetch the host ID. | |
53 | mainLoop() | |
54 | end | |
55 | ||
56 | term.clear() | |
57 | term.setCursorPos(1,1) | |
58 | intro() |