Posted 28 August 2014 - 03:50 AM
Ok hello there
I have been attempting to program a time lock for my vault in minecraft. I can barely program a password protected door, actually let me restate that: I CAN'T! I want this program to first write <Insert Keycards> on 3 monitors connect to each other. Then the computer receives a redstone pulse from my AND gate which is hooked up to 2 mag-card readers (Immibis Core mod). Then after this pulse the clock starts to countdown from 3:00 to 0:00(all displayed on a monitor centered on the screen) then outputs a redstone pulse from the back of the computer to open the vault. I want there to be a ":" separating the minutes from the seconds which complicates things a lot. And of course that to be on a monitor I wanted to also include a restart of the time lock triggered by a redstone pulse and then restart the program. The error is about an end supposed the while statement before i start any of the else if statements, but the problem is that I want this loop to include all the else if statements. It is a bit repetitive. Here is what I came up with:
local monitor = peripheral.wrap("bottom")
monitor.setTextScale(1.5)
monitor.setCursorPos(2,2)
monitor.write("<Insert Keycards>")
os.pullEvent("redstone")
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
monitor.write("3:00")
m = 2 – minutes
s = 59 – seconds
while m ~= 0 and s ~= 0 do
elseif s == 0 then
sleep(1) – 1 second pause
m = m-1
s = 59
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
monitor.write(m,":",s)
elseif s < 10 then
sleep(1)
s = s - 1
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
monitor.write(m,":0",s)
elseif s < 60 then
sleep(1)
s = s - 1
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
end
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
monitor.write("0:00")
sleep(3)
rs.setOutput("back, true")
sleep(20)
rs,setOutput("back, false")
os.reboot() – end of the program
P.S. - I tried to gather as much information on how to make a countdown timer and this is what I come up with
I have been attempting to program a time lock for my vault in minecraft. I can barely program a password protected door, actually let me restate that: I CAN'T! I want this program to first write <Insert Keycards> on 3 monitors connect to each other. Then the computer receives a redstone pulse from my AND gate which is hooked up to 2 mag-card readers (Immibis Core mod). Then after this pulse the clock starts to countdown from 3:00 to 0:00(all displayed on a monitor centered on the screen) then outputs a redstone pulse from the back of the computer to open the vault. I want there to be a ":" separating the minutes from the seconds which complicates things a lot. And of course that to be on a monitor I wanted to also include a restart of the time lock triggered by a redstone pulse and then restart the program. The error is about an end supposed the while statement before i start any of the else if statements, but the problem is that I want this loop to include all the else if statements. It is a bit repetitive. Here is what I came up with:
local monitor = peripheral.wrap("bottom")
monitor.setTextScale(1.5)
monitor.setCursorPos(2,2)
monitor.write("<Insert Keycards>")
os.pullEvent("redstone")
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
monitor.write("3:00")
m = 2 – minutes
s = 59 – seconds
while m ~= 0 and s ~= 0 do
elseif s == 0 then
sleep(1) – 1 second pause
m = m-1
s = 59
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
monitor.write(m,":",s)
elseif s < 10 then
sleep(1)
s = s - 1
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
monitor.write(m,":0",s)
elseif s < 60 then
sleep(1)
s = s - 1
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
end
monitor.clear()
monitor.setTextScale(1.5)
monitor.setCursorPos(1,2)
monitor.write("0:00")
sleep(3)
rs.setOutput("back, true")
sleep(20)
rs,setOutput("back, false")
os.reboot() – end of the program
P.S. - I tried to gather as much information on how to make a countdown timer and this is what I come up with