SHARE
TWEET

1

a guest Jan 25th, 2020 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --------------------------------------
  2. -- startup file for disk            --
  3. --  fs.delete("1")                  --
  4. --  fs.copy("disk/1bak","1")        --
  5. --  fs.delete("start")              --
  6. --  fs.copy("disk/startup","start") --
  7. --------------------------------------
  8.  
  9. --shell.run("delete disk/1")
  10. --shell.run("copy 1 disk/1")
  11.  
  12. os.loadAPI("ocs/apis/sensor")
  13. local sideOut        = "back"
  14. local mySensor       = sensor.wrap("top")
  15. local mon            = peripheral.wrap("right")
  16. local textScale      = .5
  17. local btnTextColor   = colors.white
  18. local defaultBgColor = colors.black
  19. local headerColor    = colors.white
  20. local text      =""
  21. local monRow    = 0
  22. local cnt           = 0
  23. local players = {}
  24.  
  25.  
  26. function saveData(table,name)
  27. local file = fs.open(name,"w")
  28. file.write(textutils.serialize(table))
  29. file.close()
  30. end
  31.  
  32. function loadData(name,tab)
  33. local file = fs.open(name,"r")
  34. local data = file.readAll()
  35. data1 = data
  36. file.close()
  37. print(data1)
  38. return textutils.unserialize(data)
  39. end
  40.  
  41.  
  42.  
  43.  
  44. function heading(text,monRow)
  45.    w, h = mon.getSize()
  46.    mon.setTextColor(headerColor)
  47.    mon.setCursorPos((w-string.len(text))/2+1, monRow)
  48.    mon.write(text)
  49. end
  50.  
  51.  
  52. while true do
  53.  
  54. mon.clear()
  55. mon.setBackgroundColor(colors.blue)
  56. term.setCursorPos(1,1)
  57. mon.setCursorPos(1,1)
  58.  
  59. --****************
  60. temp = "Security System"
  61. heading(temp,1)
  62. --****************
  63. mon.setCursorPos(1,3)
  64. term.clear()
  65. cnt = 0
  66. local target_list = {}
  67. local player_table = {}
  68.  
  69.  
  70.  
  71. local data1 = ""
  72. --loadData("players_table")
  73.  
  74. target_list = mySensor.getTargets()
  75. local Reference_Table ={}
  76.  
  77. for k,v in pairs(target_list) do
  78. saveData(target_list,"test1")
  79. --X if v["Name"] == "Player" then
  80.         term.clear()
  81. --        term.setCursorPos(1,cnt)
  82.         cnt = cnt +1
  83.        
  84.         table.insert(player_table,k) -------
  85.         -- print(k) -------
  86. --  cnt = cnt +1
  87.         mon.setCursorPos(2,cnt+2)
  88.         mon.write(cnt..") "..k)
  89.  
  90. --        mon.setCursorPos(33,cnt+2)
  91. --        mon.write(cnt..") "..k)
  92.  
  93. --X  end
  94. end
  95. -- loadData("playerName",playerName)
  96. -- ###########################################
  97. print("-------------")
  98. local file = fs.open("playerName","r")
  99. players = file.readAll()
  100. file.close()
  101. playerName = textutils.unserialize(players)
  102.  
  103.  for k, v in pairs(playerName) do
  104.         print("  "..k..") "..v) ---
  105.         mon.setCursorPos(33,k+2)
  106.         mon.write(k..") "..v)
  107.  
  108.  end        
  109.  
  110.  
  111. --for r, l in pairs(player_table) do
  112. --        print("  "..r..") "..l) ---
  113. --end        
  114.  
  115. -- saveData(target_list,"test1")
  116. saveData(player_table,"test")
  117. -- playerName
  118.  
  119. -- print('')
  120. -- print(player_table[2])
  121. sleep(3)
  122. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top