Posted 22 November 2013 - 05:40 PM
Hi,
first im from germany so sorry if my grammar is bad.
I want to have a server/monitor in my base like 3*4 advanced monitor with a list of names of turtles like Woodchopper1….
My problem is that i have no idea how i can make the handshake between server and turtle and how i can storge data.
I already try it but i have only trouble with the handshake and rednet. Caus i dont wanne loose messages and if turtle crash the data like id is still in my table…
Below you see my try to create a system. How would you guys make the handshake and the data sending thing(so that no data get lost)?
Client:
Server:
first im from germany so sorry if my grammar is bad.
I want to have a server/monitor in my base like 3*4 advanced monitor with a list of names of turtles like Woodchopper1….
My problem is that i have no idea how i can make the handshake between server and turtle and how i can storge data.
I already try it but i have only trouble with the handshake and rednet. Caus i dont wanne loose messages and if turtle crash the data like id is still in my table…
Below you see my try to create a system. How would you guys make the handshake and the data sending thing(so that no data get lost)?
Client:
rednet.open("right")
local pass = "123"
local spass = "456"
local handShake = true
while handShake do
loginShake = true
rednet.broadcast("hs")
event, id, message, dist = os.pullEvent("rednet_message")
if message == pass then
while loginShake do
rednet.send(id, spass)
l1, p1, p2, p3 = os.pullEvent("rednet_message")
if p1 == id then
if p2 == "ok" then
loginShake = false
handShake = false
end
end
end
end
end
print("Handshake!")
Server:
rednet.open("right")
local pass = "123"
local rpass = "456"
local hs = {}
local hsc = 1
while true do
event, id, message, dist = os.pullEvent("rednet_message")
if message == "hs" then
rednet.send(id, pass)
hs[hsc] = {}
hs[hsc].id = id
hs[hsc].phase = 1
hsc = hsc + 1
elseif message == rpass then
for i = 1, hsc-1 do
if id == hs[i].id then
rednet.send(hs[i].id, "ok")
hs[i].phase = 2
print("ok")
print(id)
end
end
end
end