MineMcMine

SecurityLogger

Apr 19th, 2022 (edited)
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. --[[
  2.     Using: CC: Tweaked, Plethora
  3.     pastebin run F1bcLbLQ
  4.     pastebin get F1bcLbLQ startup
  5. ]]--
  6.  
  7. if pcall(os.loadAPI, "jLib/jFuncs") then
  8. else
  9.     shell.run("pastebin get kqBFGcfV jLib/jFuncs")
  10.     os.loadAPI("jLib/jFuncs")
  11. end
  12.  
  13. local sensor = peripheral.find("manipulator")
  14. local logName = "log.txt"          
  15.  
  16. local function logChange(entity, verb)
  17.     local printStr = ("%s: %s %s!"):format(os.date("!%c"), entity, verb)
  18.     print(printStr)
  19.     local file = fs.open(logName, fs.exists(logName) and "a" or "w")
  20.     file.writeLine(printStr)
  21.     file.close()
  22. end
  23.  
  24. local lastList = {}
  25. while(true) do
  26.     for i, entity in pairs(lastList) do
  27.         lastList[i] = false
  28.     end
  29.  
  30.     for _, entity in pairs(sensor.sense()) do
  31.         if(entity.displayName ~= nil) then
  32.             if(lastList[entity.displayName] == nil and not string.find(entity.displayName, "item.tile")) then
  33.                 logChange(entity.displayName, "entered")
  34.                 lastList[entity.displayName] = true
  35.             elseif(lastList[entity.displayName] == false) then
  36.                 lastList[entity.displayName] = true
  37.             end
  38.         end
  39.     end
  40.  
  41.     for i, entity in pairs(lastList) do
  42.         if(not lastList[i]) then
  43.             logChange(i, "left")
  44.             lastList[i] = nil
  45.         end
  46.     end
  47.  
  48.     if(not redstone.getOutput("left") and lastList["EvilKurt2"]) then
  49.         redstone.setOutput("left", true)
  50.     elseif(redstone.getOutput("left") and not lastList["EvilKurt2"]) then
  51.         redstone.setOutput("left", false)
  52.     end
  53.  
  54.     os.sleep(1)
  55. end
  56.  
  57.  
  58.  
Add Comment
Please, Sign In to add comment