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

[1.4] SSP os.sleep not working correctly.....

Started by Shivam619, 20 September 2012 - 07:58 AM
Shivam619 #1
Posted 20 September 2012 - 09:58 AM
I cant get this simple program to work because os.sleep command does not respond correctly


function actvBB (x) –this is to activate BlockBreakers
for i= 0 , 50 do
rs.setBundledOutput("left" , 8)
os.sleep (0.4)
rs.setBundledOutput("left" , 0)
end
end

this 0.4 sec delay takes about 20 secs
it worked just fine earlier in other save of mine with same settings.
EDIT: I asked it loop only once
And there are no other computer connected.


ADDITIONAL INFORMATION:
Minecraft Forge 3.3.8.152
Mtdj2 #2
Posted 20 September 2012 - 10:50 AM
Well, i dont know why os.sleep() doesnt work, try using sleep(n) instead. If none works, try updating your Forge. That might help. Or maybe, update your ComputerCraft.
Xfel #3
Posted 20 September 2012 - 11:18 AM
The sleep delay depends on the tick duration and on the number of active computers. Maybe you're having a lot of working computers besides?
MysticT #4
Posted 20 September 2012 - 06:07 PM
How do you know how much the delay takes? By looking at the cable?
You forgot to put a sleep after setting the output to 0 (off), so it will loop back instantly and turn it on, and it will look like it never turned off.
So…
0.4 seconds x 50 iterations = cable is on 20 seconds
Mr. Fang #5
Posted 21 September 2012 - 01:05 AM
LOL I feel so noobish reading this and not understanding…
Zoinky #6
Posted 21 September 2012 - 09:57 AM
LOL I feel so noobish reading this and not understanding…
Basicly, Instead of stopping a little bit to turn the cable off it instantly loops back to rs.setBundledOutput("left" , 8) because there is no sleep(n). Think of it like this, The cable turns on, waits 0.4 seconds then turns off and instantly back on because of the loop. Having a sleep(0.4) would fix this. :)/>/>
Oh and… That was quite a pointless post? No offence.
Shivam619 #7
Posted 21 September 2012 - 11:39 AM
How do you know how much the delay takes? By looking at the cable?
You forgot to put a sleep after setting the output to 0 (off), so it will loop back instantly and turn it on, and it will look like it never turned off.
So…
0.4 seconds x 50 iterations = cable is on 20 seconds
so I edited the info and I stand strongly with my point.
Fatal_Exception #8
Posted 21 September 2012 - 02:28 PM

rs.setBundledOutput("left" , 8)
os.sleep (0.4)
rs.setBundledOutput("left" , 0)
os.sleep (0.4) --  <-- THIS
MysticT #9
Posted 21 September 2012 - 03:09 PM
Add a print(i) inside the loop, and you'll see that it loops 50 times.
When you see that you're wrong, add the second sleep that we said and it will work.
sjele #10
Posted 21 September 2012 - 07:30 PM
Let's try to make a painting to explain this,
http://s1182.photobucket.com/albums/x444/sjele/?action=view&amp;current=Explaining_zps94676460.png

The lines made by the pencil are instant, they are there just to show how it moves thru the loop