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

OpenCCSensors - Proximity Sensor bugged ?

Started by Matplotlib, 10 August 2016 - 09:28 PM
Matplotlib #1
Posted 10 August 2016 - 11:28 PM
Hello there !
First of all I'm running MC 1.7.10, CC 1.75 and OpenCCSensors 1.6.4.5. I also use Greg's Stargate Mod, but it doesn't take any place in this program I'm working on.

I basically need to detect if the player enters in a specific area (materialized by a cylinder all around the sensor) to trigger or not a redstone signal (that will afterwards open or close the gate's iris).
I made this program based on the wiki's second example : http://pastebin.com/kTWeHA6n.

I don't know why it is going wrong, but the thing is I don't get any error message (everything works fine, but not as expected).
It looks like the program is only able to change the redstone output once ; after that, no matter I enter or leave the area, it just won't change the output !

Is it a bug coming from the OpenCCSensors API ? Should I use another sensor card ? Even the sensors block ?
Thanks already for your replies ;)/>
KingofGamesYami #2
Posted 11 August 2016 - 12:18 AM
You should sleep for at least 0.05 seconds after setting the redstone, as MC can't update faster than that.
Bomb Bloke #3
Posted 11 August 2016 - 03:26 AM
Truth be told, the redstone tick rate is 0.1 - half the server tick rate speed. That's not really a problem here, though, as the signal should simply be off when he's close and on when he's not - but adding a sleep of a few seconds each iteration would take a fair load off the Minecraft server without opening up any major security holes in the door system.

I'm not seeing anything obvious in the code that'd prevent it from working as expected, though. If I were you I'd have the script print whether "me" is nil or not and what the detected radius is. That should give you some clues.
Matplotlib #4
Posted 11 August 2016 - 12:57 PM
Alright, thanks a lot to both of you, it appears adding a os.sleep(0.1) at the end of the while loop slved the problem !
You guys deserve a +1 ;)/>