Spoiler
prox = peripheral.wrap("top")
mon = peripheral.wrap("right")
while true do
players = prox.getPlayers()
mon.clear()
mon.setCursorPos(2,3)
mon.write(players)
if players ~= "{}" then
local h = fs.open("visitor", fs.exists("visitor") and "a" or "w")
h.writeLine(players)
h.close()
end
sleep(5)
end
What I would like to do is to write to the "visitor" file every time someone comes in my base their name and the time of visit, it can be ingame time or real time, doesn't matter but the problem is I can't figure out a way to pull out player names from the tables and I can't figure out how to not write to the file when no one is near and also not to have double entries of the same player, also I don't know how to deal with the table if there are two players near the sensor at the same time or more, currently it is writing "{}" every 5 seconds when no one is near the sensor. I looked at a lot of code and I just got even more confused. I am playing on a direwolf20 1.8.0 pack server.
Thank you for your time!