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

OS Error

Started by TheRavenBlue, 10 July 2013 - 01:59 PM
TheRavenBlue #1
Posted 10 July 2013 - 03:59 PM
Tite: OS Error

I cant find where i have put wrong here:



pass = "BaseSecret"
welcomeMsg = "Enter Security Code:"
successMsg = "Acces Granted"
failedMsg = "Acces Denied"
doorDelay = 2
coolDown = 5 –time beteewn fails
doorDir = "back"

term.clear()
term.setCursorPos(1,1)
print(welcomeMsg)
input = read("*")
if input == pass then
print(successMsg)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(DoorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
os.shutdown()
else
print(failedMsg)
sleep(coolDown)
os.shutdown()
Yevano #2
Posted 10 July 2013 - 08:01 PM
There's no end to end your if statement. Also, use code tags when putting code in a post.
MR_nesquick #3
Posted 10 July 2013 - 11:16 PM
yeah you are missing 'end' on your last line..


btw i took the time to make it shorter. :)/>

local pass = "BaseSecret"
local welcomeMsg = "Enter Security Code:"
local successMsg = "Acces Granted"
local failedMsg = "Acces Denied"
local doorDelay = 2
local coolDown = 5 --time beteewn fails
local doorDir = "back"
local pulseAmout = 6

term.clear()
term.setCursorPos(1,1)
print(welcomeMsg)
input = read("*")
if input == pass then
for i = 1,pulseAmout do
print(successMsg)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
end
os.shutdown()
else
print(failedMsg)
sleep(coolDown)
os.shutdown()
end

why are you pulsing your redstone signal?
Zudo #4
Posted 11 July 2013 - 01:39 AM
Please, please use code tags :(/>


redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(DoorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
sleep(doorDelay)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)

could be turned into:


for i = 1, 6 do
sleep(doorDelay)
redstone.setOutput(doorDir,true)
sleep(doorDelay)
redstone.setOutput(doorDir,false)
end

And it's easier to modify!
TheRavenBlue #5
Posted 11 July 2013 - 07:21 AM
Im creating a secret door with frame engines to pull back the floor thats why i have it pulsing