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

[Lua] [Error] [Question] redstone outputs

Started by mupplol, 01 January 2013 - 05:35 AM
mupplol #1
Posted 01 January 2013 - 06:35 AM
Hello, im trying to get a hatch to open when i type "open" in the computer, but its not working at all.

I get "startup :9: attempt to call nil every time and i cant figure out what to do. The code is below

Oh, and am i doing it correct to get it to pulse 11 times on top? Thanks!

val1 = "open"
print("type open")
write "root: "
input = read()
if val1 == val1 then


redstone.setOutput("left",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
redstone.setOutput("top",true)
sleep(0.85)
ChunLing #2
Posted 01 January 2013 - 07:05 AM
Which is line 9, as it appears when you open startup in edit.
mupplol #3
Posted 01 January 2013 - 07:46 AM
Its the first "redstone.setOutput("top",true)"

And since im completely new to Lua, i cant figure out what it is, not even after a few hours on youtube and reading forums :(/>
ChunLing #4
Posted 01 January 2013 - 10:51 AM
Are you positive that it is exactly as it appears here?

Oh, little hint, for something like this, you'll want to turn the redstone on and turn it off. The good news is that you can use a for loop, which is a good bit less tedious. Thus:
for i=1,11 do
  rs.setOutput("top",true)
  sleep(0.25) -- how long it's on
  rs.setOutput("top",false)
  sleep(0.6) -- how long it's off
end
The entire redstone api function table is also accessible by rs, which is a bit of help in avoiding possible typos.
Edited on 01 January 2013 - 09:56 AM
remiX #5
Posted 01 January 2013 - 12:58 PM
Reboot the computer and then try? Maybe you overwrote the redstone api at some stage with out knowing.

Also, why are you comparing val1 with val1? It will always be equal :P/>