Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- currentScroll = 0;
- turtles = 0;
- tIds = {}
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- function writeIn(x, y, text)
- local i,j = term.getSize()
- --if y < j then
- term.setCursorPos(x, y)
- write(text);
- --end
- end
- function draw()
- local x,y = term.getSize()
- clear()
- local posX, posY, posZ = gps.locate();
- print("Turtle Manager (#" .. os.getComputerID() .. ") (" .. turtles .. ")");
- rednet.open("top")
- for i = 0, x do
- term.setCursorPos(i,2)
- write("-")
- end
- for i = 0, turtles do
- --writeIn(1, 3 + (i + currentScroll) % (y - 2), "#" .. index);
- if(tIds[i] ~= nil) then
- writeIn(1, 3 + i, tIds[i .."name"] .. "(#" ..tIds[i]..")")
- end
- end
- currentScroll = (currentScroll + 1);
- end
- function string:split( inSplitPattern, outResults )
- if not outResults then
- outResults = { }
- end
- local theStart = 1
- local theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
- while theSplitStart do
- table.insert( outResults, string.sub( self, theStart, theSplitStart-1 ) )
- theStart = theSplitEnd + 1
- theSplitStart, theSplitEnd = string.find( self, inSplitPattern, theStart )
- end
- table.insert( outResults, string.sub( self, theStart ) )
- return outResults
- end
- while true do
- local id, message = rednet.receive(1)
- if(message ~= nil) then
- local sMessage = message:split(":")
- if(sMessage[0] == "ayylmao") then
- local isNew = true;
- for i = 0, turtles do
- if(tIds[i] == id) then
- isNew = false;
- end
- end
- if(isNew)then
- tIds[turtles] = id;
- tIds[turtles .. "label"] = sMessage[1]
- turtles = turtles + 1;
- end
- end
- end
- draw(id, message)
- end
Advertisement
Add Comment
Please, Sign In to add comment