4 posts
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
62 posts
Location
Behind you
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.
510 posts
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?
1604 posts
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
79 posts
Posted 21 September 2012 - 01:05 AM
LOL I feel so noobish reading this and not understanding…
144 posts
Location
Wellington, New Zealand
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.
4 posts
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.
105 posts
Posted 21 September 2012 - 02:28 PM
rs.setBundledOutput("left" , 8)
os.sleep (0.4)
rs.setBundledOutput("left" , 0)
os.sleep (0.4) -- <-- THIS
1604 posts
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.
318 posts
Location
Somewhere on the planet called earth
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&current=Explaining_zps94676460.pngThe lines made by the pencil are instant, they are there just to show how it moves thru the loop