I am trying to create a redstone pulse output on a timer within my monitor script.
Basically I have a marquee on my monitor in my shop but people keep tampering with it. So I wish to punish them by activating my coils located under the monitor when a key is pressed.
I am using os.pullEvent() with event=="key" to activate my function which is:
rs.setOutput("left", true)
rs.setOutput("right", true)
sleep(4)
rs.setOutput("left", false)
rs.setOutput("right", false)
The problem I am having is that it stops my screen after sleep() it does not seem to continue the rest of the script. Anyway around this? That I can use the timer without pausing everything else?
text = {
"array1",
"array2",
"array3"
}
function shock()
local timer = os.startTimer(4)
while true do
if event = os.pullEvent("timer")
rs.setOutput("left", true)
rs.setOutput("right", true)
sleep(0)
rs.setOutput("left", false)
rs.setOutput("right", false)
end
mon = peripheral.wrap("top")
mon.clear()
wScreen, hScreen = mon.getSize()
function Scroll()
for i = -#text,hScreen do
for t = 1 #text do
mon.setCursorPos(2, -i+1)
mon.write(text[t])
end
mon.setCursorPos(2, -i)
sleep(.3)
mon.clear()
end
end
while true do
Vertical()
end
local event = os.pullEvent()
if(event == "char") then
shock()
end