Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Turtle = {
- IDTurtle = nil,
- IDServer = nil,
- Inici = nil,
- PosActual = nil,
- Inicialitzat = false
- }
- Config = {
- timeout = 5,
- serverName = "ServidorTurtlesVic"
- }
- function main()
- Turtle:inicialitzar()
- end
- function Turtle:inicialitzar()
- rednet.open("right")
- while ( not(self.IDServer)) do
- local senderId, message = rednet.receive(5)
- if string.find(message, "IDNEW") then
- args = {}
- for k, argument in string.gmatch(message, "[^%s]+") do
- args[k] = argument
- end
- self.IDServer = args[2]
- end
- end
- self:getGPS()
- if self.PosActual == "ERROR" then
- return false
- end
- self.Inicialitzat = true
- return true
- end
- function Turtle:getGPS()
- local timeout = tonumber(Config.timeout)
- local vectorA = vector.new(gps.locate(timeout))
- if not vectorA.x then
- print(" /!\\ Error al intentar aconseguir la posició GPS /!\\ ")
- self.PosActual = "ERROR"
- else
- self.PosActual = vectorA
- end
- return true
- end
- function Turtle:getID()
- self.IDTurtle = nil --TODO Implementar
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement