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

Get the last time the computer/turtle was placed in the world.

Started by Zanoab, 28 March 2013 - 09:46 AM
Zanoab #1
Posted 28 March 2013 - 10:46 AM
When a computer, turtle, or another variant is placed in the world, a timestamp is saved to that block/tile entity. The timestamp can then be read with a built-in function by programs.

I'm currently working on my own turtle API which includes persistent data storage. It saves it's current coordinates if available, last slot, and various other details. I want my API to check the last time it was placed in the world to detect tampering and reduce the possibility of relaying incorrect information to my programs and surrounding systems.
Cloudy #2
Posted 28 March 2013 - 10:58 AM
Do it yourself in a startup script. I'm not going to implement a feature that no one will use, except you.
Cranium #3
Posted 29 March 2013 - 03:37 AM
To elaborate, in a startup script, you can actually do this yourself. Using the HTTP API, you can retreive real time via a web api, such as timeapi.org, and save that information to a file. This is more efficient than having to do it Java side, which I assume would have to do essentially the same thing, but would probably have problems determining what timezone to select without a config.
It just seems like an unnecessary step to implement something already doable in CC.
Zanoab #4
Posted 29 March 2013 - 05:47 AM
I'm asking to store the time when a turtle/computer was placed, not the time it starts up. I've been racking my brain trying to find some way but I can't find a way without false positives from chunk loading and unloading. I also don't want real time timestamps.

Edit: Forget about it. Just looked at the code and it doesn't seem easily doable.
Cloudy #5
Posted 29 March 2013 - 07:08 AM
os.time() and os.day() on first boot, save to file, profit?