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

Unknowen if bug or stupidity

Started by sodo, 30 December 2012 - 02:07 AM
sodo #1
Posted 30 December 2012 - 03:07 AM
as im not sure if this is a bug, or my own self bieng stupid, but i type in my normal lua code, all is correct etc no problems (i triple checked it) and then where it should sleep, it doesnt…. im not sure if i typed something wrong becosue the pc isnt spitting out an error but yet its still doing it, the code is(till fixed)

redstone.setOutput("left", true)
sleep=5
print("10 second wait")
sleep=10

al it does is activate the redstone and is instantly finnished, this is kind of a pain as my initial redstone needs time diferences as i said im not sure if its my own stupidity or just a bug, so im asking here

p.s., all things i tried: sleep(5) *expected =* sleep=(5) *nothing* sleep=5 *nothing* <– all those options just with os.sleep same thing

anny1 know?
FalloutBe #2
Posted 30 December 2012 - 03:11 AM
I'm not sure if this is the problem, but you can try this:

redstone.setOutput("left", true)
sleep(5.0)
print("10 second wait")
sleep(10.0)

example program which creates a 1 tick redstone pulse:

print("Pulse will come in 5 seconds from now")
sleep(5.0)
rs.setOutput("left", true)
sleep(0.1)
rs.setOutput("left", false)
print("pulse just happened")
sleep(5.0) --wait another 5 seconds so that the person has time to read the last message
sodo #3
Posted 30 December 2012 - 03:13 AM
I'm not sure if this is the problem, but you can try this:

redstone.setOutput("left", true)
sleep(5.0)
print("10 second wait")
sleep(10.0)

just tried it, still does the exact same, doesnt wait at all, the enitial program ha sa looping system in it, it works and all too, but the sleep function acts as if it wasnt there, if it helps im running craftos .14 on mindcrack v4 1.4.6
sodo #4
Posted 30 December 2012 - 03:19 AM
heres the enitial script i have for the thing to work (without prints)


for i=1,10 do
  redstone.setOutput("left, true)
  sleep(0.5)
  redstone.setOutput("left, false)
  sleep(0.5)
end

when i type in the program to start this script, it is instantly done and did nothing on the redstone….
FalloutBe #5
Posted 30 December 2012 - 03:20 AM
hmm then I don't know what's wrong, sorry :/


EDIT:
How is your redstone connected to the side? Is it red alloy wire or just redstone dust?
sodo #6
Posted 30 December 2012 - 03:25 AM
red alloy wire directly onto the computer leading streight down, it worked on tekkit 1.2.5, dont know why it wont annymore… i also tried without the off function and the wire recieves the redstone, its jsut the sleep function broke
FalloutBe #7
Posted 30 December 2012 - 03:57 AM
alright, then I can't help you :/ I thought that maybe the red alloy wire was placed on the floor next to the computer, without it going upwards up to the side.
1lann #8
Posted 30 December 2012 - 04:33 AM
Try this:


local function setAll(bool)
for _, v in pairs(rs.getSides()) do
  rs.setOutput(v, bool)
end
end

print("Start")
for i=1,10 do
  setAll(true)
  sleep(0.5)
  setAll(false)
  sleep(0.5)
end
print("End")
Orwell #9
Posted 30 December 2012 - 05:17 AM
Do you still have a "sleep=<anything>" somewhere? You could be overriding the sleep function somewhere. (or you could try "os.sleep(5)" again). Anyway, "sleep=5" is not the way to go, you're just redefining the sleep function as a number that way.
KaoS #10
Posted 30 December 2012 - 05:20 AM
heres the enitial script i have for the thing to work (without prints)


for i=1,10 do
  redstone.setOutput("left, true)
  sleep(0.5)
  redstone.setOutput("left, false)
  sleep(0.5)
end

when i type in the program to start this script, it is instantly done and did nothing on the redstone….

you didn't close your string in the redstone.setOutput command. you need another "
sodo #11
Posted 30 December 2012 - 07:00 AM
ok during the code type i forgot the " after left, is in the actual mprogramm, my bad, annyways when i try to do the sleep sleep(1.0) it says attempt to call number, witch its sposed to or am i mistakend? and the rest of the code has no sleep=**** annywhere, just that part, also where its the 1st time sleep… however, if i do the 1 1lann posted, it works…. still as clueless as before lol
sodo #12
Posted 30 December 2012 - 07:02 AM
ah, the error seemd to have fixxed itself… for some reason it wont print that error annymore…. but thanks for the help all :D/> now i can continue on this ^^
Orwell #13
Posted 30 December 2012 - 08:31 AM
My bet is that you set 'sleep' to a number before from lua terminal or a previous version of your program. Rebooting your computer fixes that. I'm glad it works now. :)/>
ChunLing #14
Posted 30 December 2012 - 08:30 PM
I should incorporate that into my sig, replace "have a sleepless night" with "set sleep = nil". Maybe replace other parts with set someFunction = nil too. For laughs.
Kingdaro #15
Posted 30 December 2012 - 08:42 PM
I should incorporate that into my sig, replace "have a sleepless night" with "set sleep = nil". Maybe replace other parts with set someFunction = nil too. For laughs.
I shouldn't be laughing this hard.
ChunLing #16
Posted 30 December 2012 - 08:50 PM
It's funny 'cause I'm mean ;)/>
Agenerick #17
Posted 01 January 2013 - 07:00 AM
Maybe try placing space between print and ("<some words>")
Lyqyd #18
Posted 01 January 2013 - 07:05 AM
Maybe try placing space between print and ("<some words>")

No. That won't change the functionality of the program either way, it just makes the code look worse, in my opinion.