Guest User

tst

a guest
Dec 23rd, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. local e = peripheral.find("EntityDetector")
  2. local w = peripheral.find("WorldInterface")
  3.  
  4. if not fs.exists("/logs/") then
  5.   fs.makeDir("/logs/")
  6. end
  7.  
  8. while true do
  9.   for i = 1, #w.getPlayerList() do
  10.     local actualPlayer = w.getPlayerList()[1]
  11.     local tActualPlayer = e.getPlayerDetail(actualPlayer)[actualPlayer]
  12.    
  13.     --fs.delete("/logs/"..actualPlayer)
  14.    
  15.     if not fs.exists("/logs/"..actualPlayer) then
  16.       local file = fs.open("/logs/"..actualPlayer, "w")
  17.      
  18.       local tPlayerInfos = {}
  19.      
  20.       local nPlayerX = math.floor(math.abs(tActualPlayer["x"]))
  21.       local nPlayerY = math.floor(math.abs(tActualPlayer["y"]))
  22.       local nPlayerZ = math.floor(math.abs(tActualPlayer["z"]))
  23.      
  24.       print(actualPlayer.."\n".."@ "..nPlayerX..", "..nPlayerY..", "..nPlayerZ)
  25.      
  26.       local nChunkX = math.floor(math.abs(nPlayerX / 16))
  27.       local nChunkY = math.floor(math.abs(nPlayerY / 16))
  28.       local nChunkZ = math.floor(math.abs(nPlayerZ / 16))
  29.      
  30.       print("C : "..nChunkX..", "..nChunkY..", "..nChunkZ)
  31.    
  32.       table.insert(tPlayerInfos, {chunkX=nChunkX, chunkY=nChunkY, chunkZ=nChunkZ, time=1})
  33.       file.write(tPlayerInfos)
  34.     else
  35.       local file = fs.open("/logs/"..actualPlayer, "r")
  36.       local tPlayerInfos = file.readAll()
  37.       tPlayerInfos = textutils.unserialise(tPlayerInfos)
  38.       file.close()
  39.      
  40.       local file = fs.open("/logs/"..actualPlayer, "w")
  41.      
  42.     end
  43.    
  44.     file.close()
  45.   end
  46.  
  47.   sleep(1)
  48. end
Advertisement
Add Comment
Please, Sign In to add comment