Posted 20 September 2012 - 03:09 PM
I was wondering if this code is sound. Right now I have no access to MC so I really can't test it.
Spoiler
--This code is used to count the number of engines and displays the number and also if they are on or off.
--mods used: CC, BC, Laser, RP2pr5b
engine = {}
state = {}
rsstate = {}
--state[1] = "Off"
--state[2] = "Off"
--state[3] = "Off"
--state[4] = "Off"
--state[5] = "Off"
--state[6] = "Off"
--state[7] = "Off"
--state[8] = "Off"
--state[9] = "Off"
--state[10] = "Off"
--state[11] = "Off"
--state[12] = "Off"
--state[13] = "Off"
--state[14] = "Off"
--state[15] = "Off"
--state[16] = 0
for i = 1, 15 do
state[i] = "Off"
engine[i] = 0
rsstate[i] = false
state[16] = 0
--rs.setBundledOutput("back" , 8024) --This sets up my laser loop
--sleep(2)
--rs.setBundledOutput("back", 0) --This turns off the colors that haven''t been set in the loop
while x ~= "end" do
for i = 1, 15 do
y = rs.getBundledInput("back")
if rsstate[i] == false and colors.test(y, 2^(i-1)) then
engine[i] = state[16] +1
state[i] = "On"
rsstate[i] = true
end
if rsstate[i] == true and colors.test(y, 2^(i-1)) == false then
rsstate[i] = false
end
end
print(" Engines | State | Total")
print("---------|---------| ",state[16]" ")
for i = 1, 15
y = rs.getBundledInput("back")
print( engine[i], "|",state[i])
end
end