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

Detect if placed or restart OR detect what dimension placed in

Started by HDeffo, 16 March 2015 - 05:25 PM
HDeffo #1
Posted 16 March 2015 - 06:25 PM
So in an attempt to get turtles unbanned from the overworld on the server I currently play on I have adjusted the rom API for turtles to only allow turtle dig commands to work when a turtle was placed with no equips and we unbanned the unequipped turtle from the overworld. I wrote the program up at around 4 AM when I was really thinking then the next day realized a huge issue I forgot about. Any server restarts or simply rebooting the turtle causes it to think it was placed with equipment and thus re-enable digging again. Anyone have some good ideas to detect dimension a turtle is placed in (owner will not allow me to raise rednet range) or detect when a turtle was placed or simply starting up again where it already was. I could add some sort of persistent value but then it wouldn't reset and allow digging again once picked up and placed in another dimension. I do have access to the rom and mod config file. The only peripheral addon we have is openperipherals which I don't believe will help much in this.
Lupus590 #2
Posted 16 March 2015 - 07:40 PM
you could modify the gps program to have the 'satellites' send which dimension they are in

instead of break and replace, make a reset program which deletes a file. the presence of this file will prevent startup from running (edit the rom startup to have this if statement, this will prevent the root/disk startup from running)

note: I'm not 100% sure on startup order but I'm very sure that it's this: /rom/startup, /rom/autorun/*, /disk/startup, /startup
Edited on 16 March 2015 - 06:42 PM
valithor #3
Posted 16 March 2015 - 07:53 PM
Assuming I understand exactly what you are trying to do you could create a autorun, which on first start creates a hidden file (file starting with .filename). After you create the file you could then overwrite the fs api to disallow opening and removing the file. The autorun could also check on turtle boot as to whether or not the turtle has the file and thus if the turtle should have digging capabilities. In summary autorun could do the following… If hidden file does not exist create it -> store whether or not to have dig capabilities -> if it does allow the turtle api to exist if not replace it with nil -> overwrite fs api to disallow modification of file in any way. If hidden file does exist -> read the file -> based on stuff in file determine whether or not to allow digging ability -> overwrite fs api to disallow modification of file in any way. This does assume the turtle does not have a label set, and the file will not be destroyed if the turtle is broken. Sorry for the bad formatting of this post I am writing this on a computer that does not allow me to hit enter while typing in these chat boxes.
Edited on 16 March 2015 - 06:55 PM
Lupus590 #4
Posted 16 March 2015 - 08:11 PM
-snip-
I am writing this on a computer that does not allow me to hit enter while typing in these chat boxes.

can you copy and paste?




here have one of mine
Edited on 16 March 2015 - 07:12 PM
valithor #5
Posted 16 March 2015 - 10:42 PM
-snip-
I am writing this on a computer that does not allow me to hit enter while typing in these chat boxes.

can you copy and paste?




here have one of mine

I probably could have, but when there is a return character in the text box at all the entire computer runs incredibly slowly. It really only happens on my really cheap laptop I have for school, and it only happens on this site.

As you might be able I am on a different computer now seeing as I hit enter :P/>
Bomb Bloke #6
Posted 17 March 2015 - 06:13 AM
Beats me why your browser's having trouble, but I'd imagine turning off the rich text editor (via the light switch at the top left of the posting box) would sort it out.
Lupus590 #7
Posted 17 March 2015 - 07:41 AM
anyway, we have gone off topic
HDeffo #8
Posted 17 March 2015 - 01:51 PM
The method valithor stated was what I was currently doing my only dilemma was hoping to allow labelled turtles to pick when they have been placed as well. Oh well seems this is the best option available and still much better than them being banned.