Jump to content




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



  • You cannot reply to this topic
9 replies to this topic

#1 Shivam619

  • Members
  • 4 posts

Posted 20 September 2012 - 08: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

#2 Mtdj2

  • Members
  • 66 posts
  • LocationBehind you

Posted 20 September 2012 - 09: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.

#3 Xfel

    Peripheral Designer

  • Members
  • 515 posts

Posted 20 September 2012 - 10: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?

#4 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 20 September 2012 - 05: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

#5 Mr. Fang

  • Members
  • 82 posts

Posted 21 September 2012 - 12:05 AM

LOL I feel so noobish reading this and not understanding...

#6 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

Posted 21 September 2012 - 08:57 AM

View PostMr. Fang, on 21 September 2012 - 12:05 AM, said:

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.

#7 Shivam619

  • Members
  • 4 posts

Posted 21 September 2012 - 10:39 AM

View PostMysticT, on 20 September 2012 - 05:07 PM, said:

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.

#8 Fatal_Exception

  • New Members
  • 105 posts

Posted 21 September 2012 - 01:28 PM

rs.setBundledOutput("left" , 8)
os.sleep (0.4)
rs.setBundledOutput("left" , 0)
os.sleep (0.4) --  <-- THIS


#9 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 21 September 2012 - 02: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.

#10 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 21 September 2012 - 06:30 PM

Let's try to make a painting to explain this,
http://s1182.photobu...zps94676460.png

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users