rs.setBundledOutput("back", 1)
sleep(1)
rs.setBundledOutput("back", 0)
sleep(1)
I wanted to label it pulse or something of that sort how would I do that?
function rs(side,t1,t2)
rs.setBundledOutput(side, t1)
sleep(1)
rs.setBundledOutput(side, t2)
sleep(1)
end
--Then Call it Like This Or Something
rs("back",1,0)
function pulse()
rs.setBundledOutput("back",1)
sleep(1)
rs.setBundledOutput("back",0)
sleep(1)
end
--run it by simply putting pulse() in the code
function pulseCol(col, side, lengthOn, lengthOff, nTimes)
if type(col) ~= "number" then error("Bad argument #1, number expected - got " .. type(col))
elseif type(side) ~= "string" then error("Bad argument #2, string expected - got " .. type(side))
elseif type(lengthOn) ~= "number" then error("Bad argument #3, number expected - got " .. type(lengthOn))
elseif type(lengthOff) ~= "number" then error("Bad argument #4, number expected - got " .. type(lengthOff))
elseif type(nTimes) ~= "number" then error("Bad argument #5, number expected - got " .. type(nTimes)) end
nTimes = nTimes or 1
lengthOn = lengthOn or 1
lengthOff = lengthOff or 1
col = col or colours.white
for i = 1, #nTimes do
c = rs.getBundledInput() + col
rs.setBundledOutput(side, c)
sleep(lengthOn)
rs.setBundledOutput(side, c - col)
sleep(lengthOff)
end
end
NIce… So if you give it a number…elseif type(lengthOn) ~= "string" then error("Bad argument #3, number expected - got " .. type(lengthOn)) elseif type(lengthOff) ~= "string" then error("Bad argument #4, number expected - got " .. type(lengthOff)) elseif type(nTimes) ~= "string" then error("Bad argument #5, number expected - got " .. type(nTimes))
NIce… So if you give it a number…elseif type(lengthOn) ~= "string" then error("Bad argument #3, number expected - got " .. type(lengthOn)) elseif type(lengthOff) ~= "string" then error("Bad argument #4, number expected - got " .. type(lengthOff)) elseif type(nTimes) ~= "string" then error("Bad argument #5, number expected - got " .. type(nTimes))
I would say avoid type checking where possible - it violates the principle of duck typing.
function Pulse()
rs.setBundledOutput("back", 1)
sleep(1)
rs.setBundledOutput("back", 0)
sleep(1)
end
and when you want the program you put this in just type Pulse() on a new line.