Posted 24 February 2012 - 07:57 AM
Hi again everyone. Im back with another question.
I'm still a noob in coding but im learning, so i have a lot of questions. :huh:/>/>
I got a part like this in my code:
how can i write it different by avoiding long elseif chains with like something shorter? i want no loop, since it will get activated by another function. Is there a way to do a check for a variable and the depending on the number, doing another little code block?
Thx for your patience
- Gorni
I'm still a noob in coding but im learning, so i have a lot of questions. :huh:/>/>
I got a part like this in my code:
--Storage filling, every pulse will have another color, not dedicated yet.
feedc = 0
function storage()
if feedc == 0 then
rs.setBundledOutput("back", colors.xxx)
sleep(0.5)
rs.setBundledOutput("back", 0)
sleep(0.25)
feedc = feedc + 1
elseif feedc == 1 then
rs.setBundledOutput("back", colors.xxx)
sleep(0.5)
rs.setBundledOutput("back", 0)
sleep(0.25)
feedc = feedc + 1
elseif feedc == 2 then
rs.setBundledOutput("back", colors.xxx)
sleep(0.5)
rs.setBundledOutput("back", 0)
sleep(0.25)
feedc = feedc + 1
elseif feedc == 3 then
rs.setBundledOutput("back", colors.xxx)
sleep(0.5)
rs.setBundledOutput("back", 0)
sleep(0.25)
feedc = feedc + 1
elseif feedc == 4 then
rs.setBundledOutput("back", colors.xxx)
sleep(0.5)
rs.setBundledOutput("back", 0)
sleep(0.25)
feedc = feedc + 1
elseif feedc == 5 then
rs.setBundledOutput("back", colors.xxx)
sleep(0.5)
rs.setBundledOutput("back", 0)
sleep(0.25)
feedc = feedc + 1
elseif feedc == 6 then
rs.setBundledOutput("back", colors.xxx)
sleep(0.5)
rs.setBundledOutput("back", 0)
sleep(0.25)
feedc = feedc + 1
elseif feedc == 7 then
rs.setBundledOutput("back", colors.xxx)
sleep(0.5)
rs.setBundledOutput("back", 0)
sleep(0.25)
feedc = 0
else
end
end
how can i write it different by avoiding long elseif chains with like something shorter? i want no loop, since it will get activated by another function. Is there a way to do a check for a variable and the depending on the number, doing another little code block?
Thx for your patience
- Gorni