Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- local w, h = term.getSize()
- local timeL = ( 5 )*60 -- time in mins
- local logf = "log1" --log file
- local prox = sensor.wrap("right")
- local function scan()
- m = prox.getTargets()
- for k , v in pairs(m) do
- if v.IsPlayer then
- local player = prox.getTargetDetails(k)
- if fs.exists(logf) then file = fs.open(logf, "a") else file = fs.open(logf, "w") end
- file.write("Username: "..player["Username"].."\n")
- file.write(tostring("Position: "..textutils.serialize(player["Position"])).."\n")
- file.write("Health: "..tostring(player["Health"]).."\n")
- file.write("FoodLevel: "..tostring(player["FoodLevel"]).."\n")
- file.write("Gamemode: "..tostring(player["Gamemode"]).."\n")
- file.write("IsAirborne: "..tostring(player["IsAirborne"]).."\n")
- file.write(textutils.formatTime( os.time(), true ) .. "\n \n")
- file:close()
- end
- end
- end
- local function setup()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- print("Starting Log:")
- print("Hit: Q to quit, L to open Log")
- end
- function main()
- setup()
- t = os.startTimer(timeL)
- while true do
- local arg = {os.pullEvent() }
- if arg[1]=="timer" and arg[2] == t then
- scan()
- t = os.startTimer(timeL)
- elseif arg[1]=="char" and arg[2]=="l" then
- shell.run("edit",logf)
- setup()
- elseif arg[1]=="char" and arg[2]=="q" then
- break
- end
- end
- end
- local ok, err = pcall(main)
- if not ok then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.white)
- print(err)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement