Jump to content




IPnet: GPS based IP system for internet protocol in Computercraft


  • You cannot reply to this topic
2 replies to this topic

#1 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 31 January 2015 - 09:59 PM

Hi guys,

I'm having a little trouble with this piece of code:

function getCientIPs()
while true do
  local event, side, ch1, ch2, msg, distance = os.pullEvent("modem_message")
  if ch1 == 65526 and ch2 == 1 then
   local clientsToAnalyse = {}
   local possibleClients = {}
   possibleClients = textutils.unserialize(msg)
   debugPrint("Possible clients: ")
   debugPrint(textutils.serialize(possibleClients))
   for i,v in pairs(clientIPs) do
    for k,m in pairs(possibleClients) do
	 if  v == m then
	  debugPrint("analyzing...")
	  clientsToAnalyse[k] = true
	 end
    end
   end
   debugPrint("Clients to analyze: ")
   debugPrint(textutils.serialize(clientsToAnalyse))
   for i,v in pairs(clientsToAnalyse) do
    if v ~= true or v == nil then
	 debugPrint("v: ")
	 debugPrint(v)
	 clientIPs[#clientIPs + 1] = possibleClients[i]
	 debugPrint("ClientIPs: ")
	 debugPrint(textutils.serialize(clientIPs))
    end
   end
  end
end
end

What it does is that it takes the table it receives from a slaveRouter with all the client IPs of the slave routers. ClientIPs reffers to the already stored ids. The table is empty in the begining. DebugPrint prints the argument if debugOpt == true. Only for debugging. So the code is not working properly. If you want the whole code just check out this website. The three programs you need start with IPnet. I hope you can help me.

Thanks in advance. :)

#2 Rougeminner

  • Members
  • 151 posts

Posted 31 January 2015 - 10:21 PM

what seems to be your error. can you write it down so we know what to look for in the code?

#3 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 01 February 2015 - 09:27 AM

The error is that when it tries to print the clientips table it only prints {}. Does it have anything tobdo with the fact that the in pairs function does not workn on empty tables





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users