This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
leonardi's profile picture

Visitors Database

Started by leonardi, 16 October 2013 - 07:35 PM
leonardi #1
Posted 16 October 2013 - 09:35 PM
Hey guys,

– Forgot to put pastebin link herpderp -.-
http://pastebin.com/U5EDn8pS


I wrote a little program today.
Basically what it does is it checks for people around your house or where ever you put the computer and logs them to a database.

This is pretty nifty for when you play on public servers and you want to see who has been snooping around your base or whatever.

It also uses the time API from http://www.timeapi.org/ to tell you exactly at what time people visited

(You might need to change around the code a bit to make it show the right time for you, It's set for Central European time now)

Pics (eventhough there is not much to show)
Spoiler

The screen you see when you start the program up for the first time.


The screen you see every time after that.



This is the database file open. as you can see it prints everyone that visited on a new line with the exact time and date.

(The first line is the name you gave in the first time you started the program up, the program will disregard this name and will not log it to the database. so that it doesn't get flooded with your own name)




Hope you guys will find a use for it.
Let me know what you think of the program and how I could have done it better / make it better.

- Leo
popdog15 #2
Posted 16 October 2013 - 09:47 PM
Interesting. Though, assuming you have MiscPeripherals, which most people do, you could have the same effect using a player detector peripheral. Which in my opinion at least, is a lot nicer to deal with as a person trying to get into a base, rather than having to type in my name.
Kodos_Atoz #3
Posted 16 October 2013 - 09:51 PM
It's been my experience that MiscPeriphs is buggy as heck. This'll come in handy for monitoring vital bits of my base =) +1 Internets to you.
theoriginalbit #4
Posted 16 October 2013 - 09:52 PM
Even better would be to use OpenPeripheral's Sensor Block, then no player interaction is needed at all!
leonardi #5
Posted 16 October 2013 - 09:55 PM
Oh no this is not the program I use to let myself into the base.

This is strictly for monitoring who gets close to it and logging it to a database.
For the sensorprogram that lets me in the front door I use this:

http://pastebin.com/TNKanRvs

Just put the names of me and people I want in my base into the program and it auto opens the door.

Also I don' t know if you noticed but you only have to enter your name the very very first time you run the program. Every time it starts up after that it remembers your name.
popdog15 #6
Posted 16 October 2013 - 11:13 PM
Oh no this is not the program I use to let myself into the base.

This is strictly for monitoring who gets close to it and logging it to a database.
For the sensorprogram that lets me in the front door I use this:

http://pastebin.com/TNKanRvs

Just put the names of me and people I want in my base into the program and it auto opens the door.

Also I don' t know if you noticed but you only have to enter your name the very very first time you run the program. Every time it starts up after that it remembers your name.
Oh, no, I didn't notice. I didn't look at the code at all, lol.
Dragon53535 #7
Posted 17 October 2013 - 12:16 AM
Just a question, is there a way to edit it so that it disregards multiple users?

Edit: Your program detects mobs too, or is there a certain card to just detect players?
Snappletree_HD #8
Posted 07 January 2016 - 02:20 AM
i get a error (program name):56: attempt to index ? (a nil value)
Anavrins #9
Posted 07 January 2016 - 03:33 AM
i get a error (program name):56: attempt to index ? (a nil value)
OpenP doesn't have "ocs/apis/sensor" anymore. I'll fix the code for the latest version of OpenP…
Edit: Here it is http://pastebin.com/zGiY8Afz
Edited on 07 January 2016 - 02:52 AM
Lyqyd #10
Posted 07 January 2016 - 04:19 AM
OpenP never did. The sensor API was part of the superior mod OpenCCSensors.
Anavrins #11
Posted 07 January 2016 - 04:23 AM
Oh that's right, well, I'm assuming he's using the sensor in OpenP.
Both OCS and OpenP options are there. :P/>